A Chrome extension that prevents popups and unwanted tabs from opening when they don't match the base URL of the current tab. Enable protection on a per-site basis and track how many popups have been blocked.
- Per-Site Protection: Enable or disable popup blocking for specific base URLs
- Smart Detection: Only blocks programmatic popups and
target="_blank"links, not user-initiated new tabs - Popup Counter: Track how many popups have been blocked for each site
- Persistent Settings: Your enabled sites and blocked counts are saved across browser sessions
- Clean UI: Simple toggle switch to enable/disable protection for the current site
When enabled for a specific base URL (e.g., https://example.com), the extension will:
- Monitor all new tabs opened from that site
- Block tabs that navigate to a different base URL
- Count and display the number of blocked popups
- Allow same-site tabs to open normally
What gets blocked:
- JavaScript popups (
window.open()) - Links with
target="_blank"to different domains - Programmatic tab openings to external sites
What doesn't get blocked:
- User-initiated new tabs (Ctrl+T, clicking the + button)
- New tabs to the same base URL
- Browser navigation (back/forward, bookmarks)
-
Clone or download this repository:
git clone https://github.com/GabrielTavernini/TabBlocker.git cd TabBlocker -
Open Chrome and navigate to
chrome://extensions/ -
Enable Developer mode (toggle in the top-right corner)
-
Click Load unpacked
-
Select the extension directory (
TabBlocker) -
The extension icon should appear in your toolbar
-
Navigate to a website that you want to protect from popups
-
Click the extension icon in your toolbar
-
The popup will show:
- The current site's base URL
- A toggle switch to enable/disable protection
- The number of popups blocked for this site
- A reset button to clear the counter
-
Toggle protection ON for the current site
-
The extension will now block any popups from that site that try to navigate to a different domain
-
You can enable/disable protection for each site independently
- News sites that open ads in new tabs
- Social media sites that open external links in new tabs
- Streaming sites with aggressive popup ads
- Download sites that open multiple tabs when you click download
The extension requires the following permissions:
tabs: To monitor tab creation and get tab informationwebNavigation: To detect programmatic tab openings and popupsstorage: To save your settings and blocked countsactiveTab: To get the current tab's URL when you open the popup
This extension:
- β Runs entirely locally on your computer
- β Does NOT send any data to external servers
- β Does NOT track your browsing history
- β Only stores enabled site URLs and blocked counts in Chrome's local storage
- Base URL: The protocol + hostname (e.g.,
https://example.com) - Storage: Uses Chrome's
storage.localAPI - Detection: Uses
webNavigation.onCreatedNavigationTargetto identify popups
BlockPopups/
βββ manifest.json # Extension configuration
βββ background.js # Service worker (main logic)
βββ popup.html # Extension popup UI
βββ popup.js # Popup logic
βββ icons/ # Extension icons
β βββ icon16.png
β βββ icon48.png
β βββ icon48-disabled.png
β βββ icon128.png
βββ README.md # This file
- background.js: Service worker that monitors tab creation and blocks unwanted popups
- popup.html/js: User interface for toggling protection and viewing stats
- manifest.json: Extension configuration with permissions and metadata
Extension not blocking popups:
- Make sure protection is enabled for the current site (toggle should be ON)
- Check that the popup is coming from the site you have protection enabled for
- Some popups may open before the page fully loads; try refreshing
Can't open any new tabs:
- This should not happen! The extension only blocks programmatic popups, not user-initiated tabs
- If you experience this, disable the extension and report an issue
Counter not updating:
- The counter updates in real-time when popups are blocked
- Click the reset button to clear the counter for the current site
Issues and pull requests are welcome! Please feel free to submit any bugs or feature requests.
Gabriel Tavernini