feat(security): implement Brave Shields-equivalent ad and tracker blo…#117
Open
Antra1705 wants to merge 1 commit into
Open
feat(security): implement Brave Shields-equivalent ad and tracker blo…#117Antra1705 wants to merge 1 commit into
Antra1705 wants to merge 1 commit into
Conversation
…cking Signed-off-by: Antra1705 <antra.1705@gmail.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
Root Cause
SuperBrowser markets itself as "Zero ads" but the promise only applied to search-result link filtering (
ad_filter.py). No network-level blocking existed for the in-app<webview>browser — every ad request, tracker pixel, and analytics script loaded exactly as it would in vanilla Chromium.Changes Made
frontend/electron/blocker.cjs(New)ElectronBlockerfrom EasyList + EasyPrivacy on bothsession.defaultSessionandsession.fromPartition('persist:superbrowser')— dual-session coverage so neither the main window nor the webview is unprotectedtrackersBlockerinstance (EasyPrivacy only) classifies blocked requests as ads vs. trackersfilterListsUpdatedAtinsettings.jsoneasylist.txt/easyprivacy.txtsnapshots fromfrontend/electron/filters/if network fetch failsblockingWhitelistinsettings.jsonusing existingsettings.get/settings.setIPC bridgeblocking:get-stats,blocking:get-settings,blocking:set-domain-enabled,blocking:togglefrontend/electron/main.cjsawait initBlocker()called insideapp.whenReady()afterregisterIpcHandlers()and beforecreateMainWindow()ECONNREFUSEDrace condition on slower machinesfrontend/electron/preload.cjsblockingnamespace onsuperBrowserDesktopbridge:getStats,getSettings,setDomainEnabled,toggle,onStatsUpdatewebviewPreloadPathfor dynamic preload injection into the webviewfrontend/electron/webview-preload.cjs(New)@cliqz/adblocker-electron-preloadto inject cosmetic CSS hide rules into guest pagesfrontend/src/App.jsxpartition="persist:superbrowser"andpreload={window.superBrowserDesktop.webviewPreloadPath}to<webview><ShieldsPanel>in the BrowserPanel toolbarfrontend/src/components/ShieldsPanel.jsx(New)frontend/package.json@cliqz/adblocker-electronand@cliqz/adblocker-electron-preloadbuild.filesTesting
Blocker engine verification (
verify_blocker.cjs):--- Adblocker Verification Script ---
Loading filter files...
Parsing combined blocker (EasyList + EasyPrivacy)...
Parsed combined blocker successfully!
Parsing trackers-only blocker (EasyPrivacy)...
Parsed trackers-only blocker successfully!
Running test cases...
URL: https://googleads.g.doubleclick.net/pagead/ads?client=ca-pub-1234
✅ Test passed!
URL: https://www.google-analytics.com/analytics.js
✅ Test passed!
URL: https://example.com/assets/main.js
✅ Test passed!
Testing serialization and deserialization...
✅ Serialization/deserialization verification passed!
🎉 ALL TESTS PASSED SUCCESSFULLY! Blocker engine is 100% correct.
Build & packaging:
npm run build— ✅ 1530 modules, built in 1.06s, zero errorsnpm run pack— ✅ native deps compiled including@cliqz/adblocker-electron, packaged for darwin/arm64node --checkon all.cjsfiles — ✅ zero syntax errorsShieldsPanel.jsx— ✅ zero errorsApplication startup logs:
[electron:wait] [SuperBrowser adblocker] Fetching fresh filter lists...
[electron:wait] [SuperBrowser adblocker] Filter lists downloaded and cached successfully.
[electron:wait] [backend] INFO: Started server process [61911]
[electron:wait] [backend] INFO: Application startup complete.
[electron:wait] [backend] INFO: Uvicorn running on http://127.0.0.1:8000
Impact
ad_filter.pysearch-link filtering is completely unchanged — no regression to existing search modes (SuperSEO, SuperAI, SuperReview)Closes #81
Screenshots