Skip to content

GabrielTavernini/TabBlocker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Base URL Tab Blocker

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.

Features

  • 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

How It Works

When enabled for a specific base URL (e.g., https://example.com), the extension will:

  1. Monitor all new tabs opened from that site
  2. Block tabs that navigate to a different base URL
  3. Count and display the number of blocked popups
  4. 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)

Installation

From Source (Developer Mode)

  1. Clone or download this repository:

    git clone https://github.com/GabrielTavernini/TabBlocker.git
    cd TabBlocker
  2. Open Chrome and navigate to chrome://extensions/

  3. Enable Developer mode (toggle in the top-right corner)

  4. Click Load unpacked

  5. Select the extension directory (TabBlocker)

  6. The extension icon should appear in your toolbar

Usage

  1. Navigate to a website that you want to protect from popups

  2. Click the extension icon in your toolbar

  3. 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
  4. Toggle protection ON for the current site

  5. The extension will now block any popups from that site that try to navigate to a different domain

  6. You can enable/disable protection for each site independently

Example Use Cases

  • 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

Permissions

The extension requires the following permissions:

  • tabs: To monitor tab creation and get tab information
  • webNavigation: To detect programmatic tab openings and popups
  • storage: To save your settings and blocked counts
  • activeTab: To get the current tab's URL when you open the popup

Privacy

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

Technical Details

  • Base URL: The protocol + hostname (e.g., https://example.com)
  • Storage: Uses Chrome's storage.local API
  • Detection: Uses webNavigation.onCreatedNavigationTarget to identify popups

Development

Project Structure

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

Key Components

  • 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

Troubleshooting

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

Contributing

Issues and pull requests are welcome! Please feel free to submit any bugs or feature requests.

Author

Gabriel Tavernini

About

Block websites from opening annoying new tabs with different base urls 🚫

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors