Scheduled Blocker

by Ron Edgecomb

A dark browser window with a red prohibition symbol on a light gray background.

I built Scheduled Blocker as my final project for CS50x. It’s a Chrome extension that blocks the websites you choose on the days and at the times you set. Outside those hours, the sites are available as usual.

Watch the project demo on YouTube.

What it does

The extension’s toolbar popup manages both the blocked sites and the schedule. You can enter a domain or paste a complete URL, and the extension keeps the hostname. Each entry covers that domain and its subdomains, so adding youtube.com also covers www.youtube.com and m.youtube.com.

  • Set recurring periods. Choose days, a start time, and an end time for each period. Multiple periods allow breaks during the day or different hours on different days. All listed sites share the same schedule.
  • Block sites already open. Navigation checks catch new visits, and a check every minute catches tabs left open when a blocking period begins.
  • Return when the block ends. A blocked page identifies the site and shows its next available time when an opening is found within the next week. It remembers the full original URL and automatically returns to it when access becomes available.
  • Keep settings locally. Sites and periods persist between browser sessions using Chrome’s local storage. No account or server is required.

For a weekday schedule with a lunch break, you could add Monday through Friday from 9:00 AM to 1:00 PM and again from 2:00 PM to 5:00 PM. Listed sites remain available during lunch and outside those hours. Start times are inclusive, and end times are exclusive.

How it’s built

Scheduled Blocker uses JavaScript, HTML, CSS, and Chrome’s Manifest V3 extension APIs. It has no external dependencies or build step.

A background service worker handles navigation events, settings changes, and the recurring alarm that checks open tabs. Domain matching accepts an exact hostname or a subdomain separated by a dot. That keeps youtube.com from accidentally matching an unrelated hostname such as notyoutube.com.

The schedule is a list of periods, each with selected days and start and end times. A site stays blocked whenever any period covers the current local time. To find the next opening, the worker checks ahead one minute at a time, up to a week. Checking the whole schedule handles overlapping and touching periods without releasing a site while another period still applies.

The blocked page checks the clock every second and listens for settings changes. When access becomes available, it uses window.location.replace to return to the original address, replacing the blocked page’s browser history entry.

What I learned

CS50x gave me a much broader foundation to build on. Working with C, algorithms, memory, and data structures helped me understand more about how programs work and how to approach a problem. The course also gave me more practice with Python and introduced me to SQL, HTML, CSS, JavaScript, and Flask. Moving between those languages and tools helped me recognize familiar ideas in different forms.

That experience carried over into this project. I’d never built a browser extension before, so there was still plenty to figure out about how Chrome extensions are organized and how their APIs work. I could use the JavaScript, HTML, and CSS I’d learned as a starting point, then work through the unfamiliar parts by reading documentation, breaking the problem into smaller pieces, and trying things out.

Finishing Scheduled Blocker helped me see how much I’d gained from that process. I felt more comfortable starting something without already knowing every step, trusting that I could learn what I needed along the way. Building a working extension felt like a fitting way to put that into practice and finish CS50x.