mirror of
https://github.com/Dasemu/X-GeoBlock.git
synced 2026-11-26 15:26:09 +00:00
1.6 KiB
1.6 KiB
Architecture
Request flow
- The content script observes X's timeline and extracts an author from each canonical
/user/status/idlink. - The service worker checks the local cache and coalesces concurrent lookups for the same username.
- On a cache miss, the background process requests
https://x.com/<user>/aboutwith the browser's existing X session. - Chromium passes fetched HTML to an offscreen document; Firefox can parse it in its background page. When X returns only its SPA shell, an invisible same-origin frame inside the current X page renders the URL. The content script reads the location row and immediately destroys the frame. This does not create a browser tab or window.
- The worker caches the result and compares the country with the configured blacklist.
- The content script hides the post only when the country matches and the account is not followed.
Failed or ambiguous lookups fail open: the post remains visible. Empty results are never cached. Successful local and cloud lookups expire after 30 days. The user can clear the entire cache from the settings page at any time.
Browser components
background.js: networking, throttling, cache, and decisions.content.js: timeline observation and post visibility.offscreen/: isolated HTML parsing withDOMParser.lib/parser.js: DOM and embedded-data extraction.lib/config.js: defaults and country normalization.options/andpopup/: user controls.
Compatibility
The Chromium package requires Chrome 109 or newer. Firefox 109 or newer uses a browser-specific background-page manifest and does not require the Chromium offscreen-document API.