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
declarativeNetRequestengine 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 (likewindow.open,location.assign,location.replace, andwindow.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:
- Allowed Destinations (Whitelist): Manage destination domains that should always be bypassed without prompts.
- Blocked Destinations (Blacklist): Edit or clear domains blocked at the network level.
-
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.