Anti-Redirect

Anti-Redirect is a powerful, lightweight browser extension built on Manifest V3 designed to protect your browsing experience by blocking unauthorized Javascript-based redirects, sneaky link hijacks, and intrusive popups. Unlike traditional ad blockers, Anti-Redirect intercepts redirect attempts at the page level and gives you real-time control over where your browser goes. β€”

πŸš€ Key Features

  • Real-Time Redirect Detection: Intercepts Javascript navigations and shows an elegant, non-intrusive prompt banner asking for your permission before proceeding.
  • Intelligent Popup Intervention: Automatically detects and closes background popups opened via native API bypasses, offering to restore them only if approved.
  • Granular Whitelist/Blacklist Control:
    • Allow this time: One-off bypass for the current action.
    • Allow always: Whitelists the target destination domain so future navigations there are permitted.
    • Always allow source: Whitelists the originating source domain (e.g., search engines, social media networks) so redirects starting from it are never blocked.
    • Block always: Instantly blacklists the target domain and auto-blocks future connections.
  • Persistent Analytics: Tracking dashboard showing how many redirects were intercepted today and over time.
  • Dynamic Network-Level Blocking: Synchronizes your blacklist with Chrome’s native declarativeNetRequest engine to block requests efficiently at the network level.

    πŸ› οΈ Architecture & Under the Hood

    Anti-Redirect operates using a three-tier script architecture to ensure maximum coverage against bypass techniques:

    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
    β”‚                      MAIN WORLD                        β”‚
    β”‚  [page-interceptor.js]                                 β”‚
    β”‚  β€’ Monkey-patches window.open, location setters        β”‚
    β”‚  β€’ Traps redirect calls & dispatches CustomEvents      β”‚
    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                              β”‚ (CustomEvents / DOM)
    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
    β”‚                    ISOLATED WORLD                      β”‚
    β”‚  [interceptor.js]                                      β”‚
    β”‚  β€’ Listens for MAIN world events                       β”‚
    β”‚  β€’ Creates and injects the decision banner / UI       β”‚
    β”‚  β€’ Communicates with the background service worker     β”‚
    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                              β”‚ (chrome.runtime.sendMessage)
    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
    β”‚                   BACKGROUND WORKER                    β”‚
    β”‚  [service-worker.js]                                   β”‚
    β”‚  β€’ Maintains whitelists, blacklist, and stats          β”‚
    β”‚  β€’ Dynamically compiles & updates DNR network rules    β”‚
    β”‚  β€’ Tracks tab navigation creation targets              β”‚
    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
    

    1. Main World Monkey-Patching (content/page-interceptor.js)

    Runs in the main JavaScript execution context of the page (world: "MAIN"). It monkey-patches core navigation functions and properties (like window.open, location.assign, location.replace, and window.Location.prototype) to trap redirects before they load.

    2. Isolated World UI Controller (content/interceptor.js)

    Coordinates between the intercepted actions from the page and the extension’s storage. It injects a highly responsive, custom-styled HTML banner (#__anti_redirect_banner__) to obtain the user’s decision securely.

    3. Background Service Worker (background/service-worker.js)

    Acts as the central orchestrator. It manages the storage keys:

  • enabled: (Boolean) Global protection state.
  • blacklist: (Array) Blocked target domains.
  • whitelist: (Array) Allowed target domains.
  • sourceWhitelist: (Array) Trusted origin domains.
  • stats: (Object) Chronological block statistics. It dynamically updates network block rules using Chrome’s declarative rules manager when domains are added to the blacklist. β€”

    βš™οΈ Settings & Customization

    The extension provides a clean management interface divided into three settings views:

    1. Allowed Destinations (Whitelist): Manage destination domains that should always be bypassed without prompts.
    2. Blocked Destinations (Blacklist): Edit or clear domains blocked at the network level.
    3. Allowed Sources (Source Whitelist): Manage root websites (such as search engines or trusted portals) that are permitted to perform outbound navigations freely.

      πŸ”’ Permissions & Security

      To function correctly, the extension requests the following permissions in manifest.json:

  • activeTab: To inspect and inject helper assets into the currently focused tab.
  • storage: To securely persist whitelist, blacklist, and stats.
  • webNavigation: To monitor tab creation targets and suppress native window bypasses.
  • declarativeNetRequest / declarativeNetRequestWithHostAccess: To register dynamic, high-performance blocking rules directly within Chrome’s network stack without inspecting all URL payloads.
  • <all_urls> (Host Permissions): Required to intercept network requests on whitelisted and blacklisted targets across any origin.