Add Focus Blocker to block distracting sites#3
Open
arnelisk wants to merge 1 commit intolevelsio:mainfrom
Open
Add Focus Blocker to block distracting sites#3arnelisk wants to merge 1 commit intolevelsio:mainfrom
arnelisk wants to merge 1 commit intolevelsio:mainfrom
Conversation
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a 🎯 Focus tab to the popup that blocks distracting sites with one toggle. Sites you add (X, Reddit, YouTube, TikTok, etc.) get redirected to a "get back to what matters" page while focus mode is on. Each
site has its own switch so you can keep the list and just toggle individual sites on/off without re-adding them.
Built in the same spirit as the rest of the extension — no build step, no dependencies, no network calls. State lives in
chrome.storage.local(focus_enabled,focus_sites).How it works
background.js—webNavigation.onBeforeNavigatelistener checks the host against the blocklist on top-level navigations only (frameId === 0,http(s)only) and redirects toblocked.htmlwhen focusmode is on.
blocked.html— minimal static page (no JS deps) that shows which host was blocked, pulled from the query string.popup.{html,js}— new Focus tab with a master toggle, quick-add chips for common time sinks, a free-text input, and per-site on/off switches.host === s.host || host.endsWith("." + s.host)), so addingx.comalso blocksmobile.x.com.Design choices that match the project rules
webNavigation(already granted for the redirect tracer) andstorage.blocked.htmlis declared inweb_accessible_resourcessochrome.runtime.getURLcan navigate to it.Test plan
x.comvia quick-add chip; toggle focus mode on; visithttps://x.com→ should redirect to blocked page.https://mobile.x.com→ should also redirect (suffix match).x.comloads normally even with focus mode on.https://www.reddit.com/r/foonormalises toreddit.com.