feat: redesign controls and configure cloud cache

This commit is contained in:
Darío Sevilla committed 2026-10-15 09:17:13 +00:00
1 parent 070e07845c
commit e12164c312
15 files changed
+178 -78

No files matched your search

+3 -2
View File
@@ -8,11 +8,11 @@ X GeoBlock is a Manifest V3 browser extension for Chromium and Firefox. While yo
- Uses X's authenticated `AboutAccountQuery` from the current page session. HTML parsing and an invisible same-origin `/about` frame remain as fallbacks, without opening tabs or windows.
- Caches account results locally for 30 days, with manual clearing available.
- Coalesces duplicate lookups and spaces network requests to reduce load on X.
- Skips followed accounts.
- Skips followed accounts by default, with a setting to apply the blocklist to them as well.
- Provides a searchable country and region checklist with flags, an enable switch, and optional hidden-post placeholders.
- Includes opt-in debug logging for every lookup and filtering decision.
- By default, stores all settings and lookup results only in browser extension storage. No data is sent to third parties unless cloud contribution is explicitly enabled.
- Supports an optional, self-hosted Cloudflare Worker + D1 collaborative cache with signed opt-in contributions and three-installation consensus.
- Uses the project Cloudflare Worker + D1 collaborative cache at `x-geoblock-cache.dariosevilla.es`, with signed opt-in contributions and three-installation consensus.
## Install from source in Chromium
@@ -57,6 +57,7 @@ The location picker contains the ISO 3166-1 countries, plus Kosovo, using Englis
- `offscreen`: parses returned HTML without opening visible tabs.
- `declarativeNetRequestWithHostAccess`: removes anti-framing response headers only from `x.com/*/about` subframe requests so the fallback can render.
- `https://x.com/*`: reads About pages and runs the feed filter on X.
- `https://x-geoblock-cache.dariosevilla.es/*`: looks up confirmed shared location results and submits observations only when contribution is enabled.
## License
+6 -5
View File
@@ -53,6 +53,7 @@ async function lookupUser(username, followingHint = null, tabId = null) {
async function lookupUserInternal(username, key, followingHint, tabId) {
const settings = await extensionApi.storage.sync.get(XGeoConfig.DEFAULT_SETTINGS);
settings.cloudCacheEndpoint = XGeoConfig.CLOUD_CACHE_ENDPOINT;
emitDebug(tabId, settings.debugMode, "Lookup started", { username, followingHint });
const stored = await extensionApi.storage.local.get(CACHE_KEY);
const cache = stored[CACHE_KEY] || {};
@@ -68,18 +69,18 @@ async function lookupUserInternal(username, key, followingHint, tabId) {
await extensionApi.storage.local.set({ [CACHE_KEY]: cache });
} else emitDebug(tabId, settings.debugMode, "Local cache miss", { username });
if (followingHint === true) {
if (followingHint === true && settings.skipFollowed) {
emitDebug(tabId, settings.debugMode, "Author is followed; allowing post", { username });
return decision({ country: null, following: true }, settings, false);
}
if (followingHint === false && settings.cloudCacheEndpoint) {
if ((followingHint !== true || !settings.skipFollowed) && settings.cloudCacheEndpoint) {
try {
emitDebug(tabId, settings.debugMode, "Cloud cache lookup", { username, endpoint: settings.cloudCacheEndpoint });
const cloud = await XGeoCloud.lookup(settings.cloudCacheEndpoint, [key]);
const hit = cloud.get(key);
if (hit?.status === "confirmed" && hit.location) {
emitDebug(tabId, settings.debugMode, "Cloud cache hit", { username, country: hit.location, confidence: hit.confidence, confirmations: hit.confirmations });
const record = { country: hit.location, following: false, checkedAt: Date.now(), source: "cloud" };
const record = { country: hit.location, following: followingHint === true, checkedAt: Date.now(), source: "cloud" };
cache[key] = record;
await extensionApi.storage.local.set({ [CACHE_KEY]: cache });
return decision(record, settings, false);
@@ -94,7 +95,7 @@ async function lookupUserInternal(username, key, followingHint, tabId) {
emitDebug(tabId, settings.debugMode, "Direct X lookup started", { username });
const lookupLog = (event, data = {}) => emitDebug(tabId, settings.debugMode, event, { username, ...data });
const result = await enqueue(() => fetchAbout(username, lookupLog, tabId));
const record = { ...result, checkedAt: Date.now() };
const record = { ...result, following: result.following ?? followingHint, checkedAt: Date.now() };
emitDebug(tabId, settings.debugMode, "Direct X lookup completed", { username, country: record.country, following: record.following });
if (record.country || record.following === true) {
cache[key] = record;
@@ -127,7 +128,7 @@ function decision(record, settings, cached) {
ok: true,
country: record.country,
following: record.following === true,
blocked: record.following !== true && XGeoConfig.isBlacklisted(record.country, settings.blacklist),
blocked: XGeoConfig.shouldBlock(record.country, settings.blacklist, record.following, settings.skipFollowed),
cached
};
}
+1 -1
View File
@@ -7,7 +7,7 @@
3. On a cache miss, the extension first parses `https://x.com/<user>/about`, then asks the current X page to run the authenticated `AboutAccountQuery` and reads `about_profile.account_based_in`.
4. If both direct methods fail, an invisible same-origin frame renders the `/about` URL. A static network rule removes CSP and `X-Frame-Options` only from matching `/about` subframe responses. The content script reads the location row and immediately destroys the frame. This does not create a browser tab or window.
5. The worker caches the result and compares the country with the configured blacklist.
6. The content script hides the post only when the country matches and the account is not followed.
6. The content script hides the post when the country matches. Followed accounts are exempt by default; the user can disable that exemption.
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.
+1 -1
View File
@@ -1,6 +1,6 @@
# Collaborative cloud cache
The optional cloud cache uses the Cloudflare Worker and D1 schema in `worker/`. It is disabled until a user enters a deployed Worker URL in extension settings. Contributing observations is a separate opt-in choice.
The cloud cache uses the Cloudflare Worker and D1 schema in `worker/`. Extension builds use `https://x-geoblock-cache.dariosevilla.es` for reads. Contributing observations is a separate opt-in choice.
## Data flow
+1 -1
View File
@@ -6,4 +6,4 @@ The extension reads public account About pages from `x.com` using the X session
The extension reads post author links in X timelines only to decide whether to display those posts. It does not read or store post text.
The optional collaborative cache is disabled until a Worker URL is configured. Cloud reads send SHA-256 hashes of public usernames. If contribution is enabled separately, signed reports also contain the observed location, timestamp, and parser version. The service never receives following relationships, blacklist settings, post contents, or raw usernames. Public username hashes remain enumerable and must not be treated as anonymous data.
The collaborative cache at `x-geoblock-cache.dariosevilla.es` receives SHA-256 hashes of public usernames for lookups. If contribution is enabled separately, signed reports also contain the observed location, timestamp, and parser version. The service never receives following relationships, blacklist settings, post contents, or raw usernames. Public username hashes remain enumerable and must not be treated as anonymous data.
+9 -2
View File
@@ -1,12 +1,15 @@
(function (root) {
"use strict";
const CLOUD_CACHE_ENDPOINT = "https://x-geoblock-cache.dariosevilla.es";
const DEFAULT_SETTINGS = Object.freeze({
enabled: true,
blacklist: [],
skipFollowed: true,
showPlaceholder: false,
debugMode: false,
cloudCacheEndpoint: "",
cloudCacheEndpoint: CLOUD_CACHE_ENDPOINT,
contributeCloudCache: false
});
@@ -52,7 +55,11 @@
);
}
const api = { DEFAULT_SETTINGS, normalizeCountry, isBlacklisted };
function shouldBlock(country, blacklist, following, skipFollowed = true) {
return !(skipFollowed && following === true) && isBlacklisted(country, blacklist);
}
const api = { CLOUD_CACHE_ENDPOINT, DEFAULT_SETTINGS, normalizeCountry, isBlacklisted, shouldBlock };
root.XGeoConfig = api;
if (typeof module !== "undefined") module.exports = api;
})(typeof globalThis !== "undefined" ? globalThis : this);
+2 -4
View File
@@ -15,10 +15,8 @@
"declarativeNetRequestWithHostAccess"
],
"host_permissions": [
"https://x.com/*"
],
"optional_host_permissions": [
"https://*/*"
"https://x.com/*",
"https://x-geoblock-cache.dariosevilla.es/*"
],
"background": {
"service_worker": "background.js"
+37 -13
View File
@@ -1,13 +1,37 @@
:root { color-scheme: light dark; font: 16px/1.5 system-ui, sans-serif; }
body { margin: 0; background: #0f1419; color: #e7e9ea; }
main { max-width: 650px; margin: 48px auto; padding: 0 24px; }
.brand { display:flex; align-items:center; gap:16px; }.brand img { width:64px; height:64px; object-fit:contain; flex:0 0 auto; }h1 { font-size: 32px; margin:0 0 4px; }.lead,.hint { color: #8b98a5; }.lead { margin:0; }.hint { margin: 6px 0 8px; font-size: 14px; }
fieldset { border: 0; padding: 0; margin: 28px 0 0; } legend { font-size: 18px; font-weight: 700; padding: 0; }
input[type=search],input[type=url] { box-sizing: border-box; flex: 1; width:100%; min-width: 180px; border: 1px solid #536471; border-radius: 999px; background: #000; color: inherit; padding: 10px 14px; font: inherit; }
.check { display: block; margin: 22px 0; }.check input { margin-right: 8px; }.actions { display: flex; gap: 12px; margin-top: 28px; }
button { border: 0; border-radius: 999px; background: #1d9bf0; color: #fff; padding: 10px 18px; font-weight: 700; cursor: pointer; }
button.secondary { background: transparent; border: 1px solid #536471; }#status { min-height: 24px; color: #00ba7c; }
.country-tools { display: flex; gap: 12px; align-items: center; margin: 14px 0 8px; }.link-button { background: transparent; color: #1d9bf0; padding: 8px; white-space: nowrap; }
.selection-count { color: #8b98a5; margin: 8px 0; font-size: 14px; }.country-list { display: grid; grid-template-columns: repeat(auto-fill,minmax(190px,1fr)); gap: 6px; max-height: 430px; overflow: auto; border: 1px solid #2f3336; border-radius: 12px; padding: 10px; background: #000; }
.country-option { display: flex; align-items: center; gap: 9px; padding: 7px 8px; margin: 0; border-radius: 8px; cursor: pointer; }.country-option:hover { background: #16181c; }.country-option[hidden] { display: none; }.country-flag { font-size: 20px; line-height: 1; }.country-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cloud-settings { border-top:1px solid #2f3336; padding-top:24px; }.cloud-settings label:not(.check) { display:block; margin:14px 0 7px; font-weight:700; }
:root { color-scheme:dark; font:15px/1.5 Inter,ui-sans-serif,system-ui,sans-serif; --bg:#060a0e; --panel:#0b1218; --panel2:#0e1820; --line:#1b2b36; --line2:#28404d; --text:#e8f7fb; --muted:#78909c; --cyan:#45e6ff; --lime:#adff2f; --amber:#ffbe55; }
* { box-sizing:border-box; }
body { margin:0; min-height:100vh; background:radial-gradient(circle at 70% -20%,#102c39 0,transparent 38%),var(--bg); color:var(--text); }
body::before { content:""; position:fixed; inset:0; pointer-events:none; opacity:.22; background-image:linear-gradient(rgba(69,230,255,.055) 1px,transparent 1px),linear-gradient(90deg,rgba(69,230,255,.055) 1px,transparent 1px); background-size:32px 32px; mask-image:linear-gradient(to bottom,#000,transparent 80%); }
.noise { position:fixed; inset:0; pointer-events:none; opacity:.025; background-image:url("data:image/svg+xml,%3Csvg viewBox='0 0 160 160' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"); }
main { position:relative; width:min(920px,calc(100% - 40px)); margin:0 auto; padding:46px 0 70px; }
.masthead { display:flex; align-items:center; justify-content:space-between; margin-bottom:30px; }
.identity { display:flex; align-items:center; gap:17px; }
.logo-shell { width:68px; height:68px; display:grid; place-items:center; border:1px solid #285064; border-radius:16px; background:linear-gradient(145deg,#132935,#081117); box-shadow:0 0 38px rgba(69,230,255,.1),inset 0 1px rgba(255,255,255,.04); }
.logo-shell img { width:53px; height:53px; object-fit:contain; }
.kicker,.section-tag,.system-state,.counter,.connected,.endpoint,.actions button { font-family:"SFMono-Regular",Consolas,"Liberation Mono",monospace; letter-spacing:.1em; }
.kicker,.section-tag { margin:0 0 3px; color:var(--cyan); font-size:10px; font-weight:700; }
h1 { margin:0; font-size:34px; line-height:1.1; letter-spacing:-.035em; }
.lead { margin:5px 0 0; color:var(--muted); font-size:14px; }
.system-state { display:flex; align-items:center; gap:10px; padding:10px 13px; border:1px solid var(--line); border-radius:8px; background:rgba(8,16,21,.7); }
.system-state small,.system-state strong { display:block; font-size:9px; }.system-state small { color:var(--muted); }.system-state strong { margin-top:2px; color:var(--lime); }
.state-dot { width:9px; height:9px; border-radius:50%; background:var(--lime); box-shadow:0 0 13px rgba(173,255,47,.75); }
form { display:grid; gap:16px; }
.panel { position:relative; padding:25px; border:1px solid var(--line); border-radius:14px; background:linear-gradient(145deg,rgba(14,24,32,.96),rgba(8,14,19,.97)); box-shadow:inset 0 1px rgba(255,255,255,.025),0 18px 50px rgba(0,0,0,.12); }
.panel::after { content:""; position:absolute; top:-1px; left:25px; width:70px; height:1px; background:var(--cyan); box-shadow:0 0 10px var(--cyan); opacity:.65; }
.master-panel { display:grid; grid-template-columns:auto 1fr auto; align-items:center; gap:20px; }
.panel-index { color:#294450; font:700 36px/1 "SFMono-Regular",Consolas,monospace; }
.panel-copy h2,.section-head h2 { margin:0; font-size:20px; letter-spacing:-.015em; }.panel-copy p:last-child,.hint { margin:5px 0 0; color:var(--muted); font-size:13px; }
.section-head { display:flex; align-items:flex-start; justify-content:space-between; gap:20px; margin-bottom:18px; }
.counter { flex:none; margin-top:4px; padding:6px 9px; border:1px solid var(--line2); border-radius:5px; color:#9db4bf; font-size:9px; }
.switch { display:flex; align-items:center; gap:9px; cursor:pointer; }.switch input { position:absolute; opacity:0; }.switch b { color:var(--muted); font:700 9px "SFMono-Regular",Consolas,monospace; letter-spacing:.1em; }.track { width:48px; height:26px; padding:4px; border:1px solid #2a3c46; border-radius:99px; background:#111b21; transition:.2s; }.track span { display:block; width:16px; height:16px; border-radius:50%; background:#657b86; transition:.2s; }.switch input:checked + .track { border-color:rgba(69,230,255,.7); background:rgba(69,230,255,.1); }.switch input:checked + .track span { transform:translateX(22px); background:var(--cyan); box-shadow:0 0 12px rgba(69,230,255,.75); }.switch input:checked ~ b { color:var(--cyan); }
.country-tools { display:flex; align-items:center; gap:10px; margin-bottom:11px; }.search-shell { flex:1; display:flex; align-items:center; gap:10px; padding:0 13px; border:1px solid var(--line2); border-radius:8px; background:#070c10; color:var(--cyan); }.search-shell:focus-within { border-color:#3cbdd0; box-shadow:0 0 0 3px rgba(69,230,255,.07); }.search-shell input { width:100%; border:0; outline:0; padding:11px 0; background:transparent; color:var(--text); font:inherit; }.search-shell input::placeholder { color:#506872; }
button { cursor:pointer; }.ghost,.primary,.danger { border-radius:7px; padding:11px 14px; font-weight:700; }.ghost { border:1px solid var(--line2); background:transparent; color:#8da4ae; font:700 9px "SFMono-Regular",Consolas,monospace; letter-spacing:.08em; }.ghost:hover { border-color:var(--cyan); color:var(--cyan); }
.country-list { display:grid; grid-template-columns:repeat(auto-fill,minmax(190px,1fr)); gap:7px; max-height:420px; overflow:auto; scrollbar-color:#284550 #081016; padding:10px; border:1px solid var(--line); border-radius:10px; background:#070c10; }
.country-option { display:flex; align-items:center; gap:9px; min-width:0; padding:8px 9px; border:1px solid transparent; border-radius:7px; cursor:pointer; transition:.15s; }.country-option:hover { border-color:#203844; background:#0e1a21; }.country-option:has(input:checked) { border-color:rgba(69,230,255,.32); background:rgba(69,230,255,.075); }.country-option[hidden] { display:none; }.country-option input { accent-color:var(--cyan); }.country-flag { font-size:19px; line-height:1; }.country-name { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-size:13px; }
.setting-grid { display:grid; grid-template-columns:repeat(2,1fr); gap:10px; }.setting-card { display:flex; align-items:flex-start; gap:11px; padding:14px; border:1px solid var(--line); border-radius:9px; background:#091017; cursor:pointer; transition:.15s; }.setting-card:hover { border-color:#2d4a58; }.setting-card input { position:absolute; opacity:0; }.checkmark { flex:0 0 auto; width:18px; height:18px; border:1px solid #34505c; border-radius:4px; background:#071015; }.setting-card input:checked + .checkmark { border-color:var(--cyan); background:var(--cyan); box-shadow:0 0 12px rgba(69,230,255,.25); }.setting-card input:checked + .checkmark::after { content:""; display:block; width:8px; height:4px; margin:4px 0 0 4px; border:solid #041014; border-width:0 0 2px 2px; transform:rotate(-45deg); }.setting-card strong,.setting-card small { display:block; }.setting-card strong { font-size:13px; }.setting-card small { margin-top:3px; color:var(--muted); font-size:11px; line-height:1.45; }
.connected { display:flex; align-items:center; gap:7px; padding:6px 9px; border:1px solid rgba(173,255,47,.22); border-radius:5px; color:var(--lime); font-size:9px; }.connected i { width:6px; height:6px; border-radius:50%; background:var(--lime); box-shadow:0 0 9px rgba(173,255,47,.75); }
.endpoint { display:grid; grid-template-columns:auto 1fr auto; align-items:center; gap:13px; margin-bottom:11px; padding:12px 13px; border:1px solid var(--line); border-radius:8px; background:#070d12; color:var(--muted); font-size:9px; }.endpoint code { overflow:hidden; color:#b8d6df; font-size:12px; letter-spacing:0; text-overflow:ellipsis; }.lock { color:#4f6873; }
.contribution { max-width:none; }
.actions { display:flex; align-items:center; justify-content:space-between; min-height:50px; padding:4px 1px; }.actions > div { display:flex; gap:10px; }.primary { border:1px solid #2bc7de; background:linear-gradient(90deg,rgba(23,158,180,.25),rgba(69,230,255,.1)); color:var(--cyan); }.primary:hover { background:rgba(69,230,255,.16); box-shadow:0 0 20px rgba(69,230,255,.1); }.danger { border:1px solid #44363a; background:transparent; color:#c28c94; }.danger:hover { border-color:#a45762; color:#ff9aa7; }#status { min-width:170px; margin:0; color:var(--lime); font:11px "SFMono-Regular",Consolas,monospace; text-align:right; }
button:focus-visible,input:focus-visible,label:has(input:focus-visible) { outline:2px solid var(--cyan); outline-offset:2px; }
@media (max-width:680px) { main { width:min(100% - 24px,920px); padding-top:24px; }.masthead { align-items:flex-start; }.system-state { display:none; }.master-panel { grid-template-columns:auto 1fr; }.master-panel .switch { grid-column:2; }.section-head { display:block; }.counter,.connected { display:inline-flex; margin-top:10px; }.setting-grid { grid-template-columns:1fr; }.endpoint { grid-template-columns:1fr; }.endpoint span { display:none; }.actions { align-items:flex-start; gap:12px; flex-direction:column; }.actions > div { width:100%; }.actions button { flex:1; }#status { text-align:left; } }
+44 -26
View File
@@ -1,27 +1,45 @@
<!doctype html>
<html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>X GeoBlock settings</title><link rel="stylesheet" href="options.css"></head>
<body><main>
<div class="brand"><img src="../icons/icon.png" alt=""><div><h1>X GeoBlock</h1><p class="lead">Hide posts based on the country shown in an account's About page.</p></div></div>
<form id="settings">
<label class="check"><input id="enabled" type="checkbox"> Enable filtering</label>
<fieldset>
<legend>Blocked countries and regions</legend>
<p class="hint">X may show a country such as “United Kingdom” or a broader region such as “West Asia”. Nothing is blocked by default.</p>
<div class="country-tools"><input id="country-search" type="search" placeholder="Search countries and regions…" autocomplete="off"><button type="button" class="link-button" id="clear-selection">Clear selection</button></div>
<p id="selection-count" class="selection-count"></p>
<div id="country-list" class="country-list"></div>
</fieldset>
<label class="check"><input id="placeholder" type="checkbox"> Show a clickable placeholder for hidden posts</label>
<label class="check"><input id="debug-mode" type="checkbox"> Enable debug logging in the X page console</label>
<fieldset class="cloud-settings">
<legend>Collaborative cloud cache</legend>
<p class="hint">Optional. Confirmed results reduce requests to X. Deploy the included Cloudflare Worker and enter its HTTPS URL.</p>
<label for="cloud-endpoint">Worker URL</label>
<input id="cloud-endpoint" type="url" placeholder="https://x-geoblock-cache.example.workers.dev" autocomplete="url">
<label class="check"><input id="cloud-contribute" type="checkbox"> Contribute locally observed locations</label>
<p class="hint">Contributions send a SHA-256 hash of the public username and its location. Following relationships, posts, and your blacklist are never uploaded.</p>
</fieldset>
<div class="actions"><button type="submit">Save settings</button><button type="button" class="secondary" id="clear">Clear user cache</button></div>
<p id="status" role="status"></p>
</form>
</main><script src="../lib/config.js"></script><script src="../lib/countries.js"></script><script src="../lib/cloud-cache.js"></script><script src="options.js"></script></body></html>
<html lang="en">
<head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>X GeoBlock // Control panel</title><link rel="stylesheet" href="options.css"></head>
<body>
<div class="noise" aria-hidden="true"></div>
<main>
<header class="masthead">
<div class="identity"><div class="logo-shell"><img src="../icons/icon.png" alt=""></div><div><p class="kicker">XGB // CONTROL SYSTEM</p><h1>X GeoBlock</h1><p class="lead">Geographic signal filtering for your X timeline.</p></div></div>
<div class="system-state"><span class="state-dot"></span><div><small>SYSTEM STATUS</small><strong>OPERATIONAL</strong></div></div>
</header>
<form id="settings">
<section class="panel master-panel">
<div class="panel-index">01</div>
<div class="panel-copy"><p class="section-tag">CORE</p><h2>Filter engine</h2><p>Analyze posts as they enter the timeline and apply your location rules.</p></div>
<label class="switch" for="enabled"><input id="enabled" type="checkbox"><span class="track"><span></span></span><b>ACTIVE</b></label>
</section>
<section class="panel">
<div class="section-head"><div><p class="section-tag">02 // TARGET MATRIX</p><h2>Blocked locations</h2><p class="hint">Select countries or broader regions reported by X. The list starts empty.</p></div><div class="counter" id="selection-count">0 locations selected</div></div>
<div class="country-tools"><label class="search-shell"><span aria-hidden="true">⌕</span><input id="country-search" type="search" placeholder="Search location database…" autocomplete="off"></label><button type="button" class="ghost" id="clear-selection">CLEAR ALL</button></div>
<div id="country-list" class="country-list"></div>
</section>
<section class="panel">
<div class="section-head"><div><p class="section-tag">03 // BEHAVIOR</p><h2>Interface controls</h2></div></div>
<div class="setting-grid">
<label class="setting-card"><input id="placeholder" type="checkbox"><span class="checkmark"></span><span><strong>Reveal controls</strong><small>Show a clickable marker where a post was hidden.</small></span></label>
<label class="setting-card"><input id="debug-mode" type="checkbox"><span class="checkmark"></span><span><strong>Diagnostic stream</strong><small>Write detailed activity to the X page console.</small></span></label>
<label class="setting-card"><input id="skip-followed" type="checkbox"><span class="checkmark"></span><span><strong>Ignore followed accounts</strong><small>Always allow posts from accounts you follow.</small></span></label>
</div>
</section>
<section class="panel cloud-panel">
<div class="section-head"><div><p class="section-tag">04 // DISTRIBUTED CACHE</p><h2>Cloud relay</h2><p class="hint">Confirmed shared results reduce requests to X. Reads are enabled automatically.</p></div><span class="connected"><i></i>CONNECTED</span></div>
<div class="endpoint"><span>ENDPOINT</span><code>x-geoblock-cache.dariosevilla.es</code><span class="lock" aria-label="Fixed endpoint">LOCKED</span></div>
<label class="setting-card contribution"><input id="cloud-contribute" type="checkbox"><span class="checkmark"></span><span><strong>Contribute observations</strong><small>Send a SHA-256 username hash and observed location. Following data, posts and your blocklist stay local.</small></span></label>
</section>
<footer class="actions"><div><button type="submit" class="primary">SAVE CONFIGURATION</button><button type="button" class="danger" id="clear">PURGE LOCAL CACHE</button></div><p id="status" role="status"></p></footer>
</form>
</main>
<script src="../lib/config.js"></script><script src="../lib/countries.js"></script><script src="../lib/cloud-cache.js"></script><script src="options.js"></script>
</body>
</html>
+5 -16
View File
@@ -4,11 +4,11 @@ const form = document.querySelector("#settings");
const enabled = document.querySelector("#enabled");
const placeholder = document.querySelector("#placeholder");
const debugMode = document.querySelector("#debug-mode");
const skipFollowed = document.querySelector("#skip-followed");
const status = document.querySelector("#status");
const countryList = document.querySelector("#country-list");
const countrySearch = document.querySelector("#country-search");
const selectionCount = document.querySelector("#selection-count");
const cloudEndpoint = document.querySelector("#cloud-endpoint");
const cloudContribute = document.querySelector("#cloud-contribute");
renderCountries();
@@ -19,7 +19,7 @@ async function load() {
enabled.checked = value.enabled;
placeholder.checked = value.showPlaceholder;
debugMode.checked = value.debugMode === true;
cloudEndpoint.value = value.cloudCacheEndpoint || "";
skipFollowed.checked = value.skipFollowed !== false;
cloudContribute.checked = value.contributeCloudCache === true;
const selected = new Set(value.blacklist.map(XGeoConfig.normalizeCountry));
countryList.querySelectorAll("input").forEach((input) => {
@@ -70,25 +70,14 @@ document.querySelector("#clear-selection").addEventListener("click", () => {
form.addEventListener("submit", async (event) => {
event.preventDefault();
const endpoint = XGeoCloud.normalizeEndpoint(cloudEndpoint.value);
if (cloudEndpoint.value.trim() && !endpoint) {
status.textContent = "Enter a valid HTTPS Worker URL.";
return;
}
if (endpoint) {
const granted = await extensionApi.permissions.request({ origins: [`${endpoint}/*`] });
if (!granted) {
status.textContent = "Host permission is required to use the cloud cache.";
return;
}
}
await extensionApi.storage.sync.set({
enabled: enabled.checked,
blacklist: Array.from(countryList.querySelectorAll("input:checked"), (input) => input.value),
showPlaceholder: placeholder.checked,
debugMode: debugMode.checked,
cloudCacheEndpoint: endpoint,
contributeCloudCache: Boolean(endpoint) && cloudContribute.checked
skipFollowed: skipFollowed.checked,
cloudCacheEndpoint: XGeoConfig.CLOUD_CACHE_ENDPOINT,
contributeCloudCache: cloudContribute.checked
});
status.textContent = "Settings saved.";
setTimeout(() => status.textContent = "", 2000);
+35 -1
View File
@@ -1 +1,35 @@
:root { color-scheme: light dark; font: 14px/1.4 system-ui,sans-serif; } body { margin: 0; min-width: 280px; background: #0f1419; color: #e7e9ea; } main { padding: 18px; } .brand { display:flex; align-items:center; gap:10px; margin-bottom:16px; }.brand img { width:36px; height:36px; object-fit:contain; }h1 { font-size: 20px; margin: 0; } label { display:block; } p { color:#8b98a5; } button { border:0; border-radius:999px; padding:8px 14px; background:#1d9bf0; color:white; font-weight:700; cursor:pointer; }
:root { color-scheme: dark; font: 14px/1.45 Inter, ui-sans-serif, system-ui, sans-serif; --bg:#070b10; --panel:#0d141c; --line:#1c2b38; --cyan:#45e6ff; --lime:#adff2f; --muted:#78909f; }
* { box-sizing:border-box; }
body { margin:0; min-width:340px; background:var(--bg); color:#edfaff; }
body::before { content:""; position:fixed; inset:0; pointer-events:none; opacity:.24; background-image:linear-gradient(rgba(69,230,255,.07) 1px,transparent 1px),linear-gradient(90deg,rgba(69,230,255,.07) 1px,transparent 1px); background-size:24px 24px; mask-image:linear-gradient(to bottom,#000,transparent 72%); }
main { position:relative; padding:20px; }
.brand { display:flex; align-items:center; gap:11px; margin-bottom:18px; }
.logo-shell { width:43px; height:43px; display:grid; place-items:center; border:1px solid #244253; border-radius:11px; background:linear-gradient(145deg,#132430,#081016); box-shadow:0 0 24px rgba(69,230,255,.09); }
.brand img { width:34px; height:34px; object-fit:contain; }
.eyebrow,.version,.status-line,.metric,.cloud-line,button { font-family:"SFMono-Regular",Consolas,"Liberation Mono",monospace; letter-spacing:.08em; }
.eyebrow { margin:0 0 1px; color:var(--cyan); font-size:9px; }
h1 { margin:0; font-size:19px; letter-spacing:-.02em; }
.version { margin-left:auto; color:#5e7482; font-size:9px; border:1px solid var(--line); padding:3px 6px; border-radius:4px; }
.status-card { overflow:hidden; border:1px solid var(--line); border-radius:12px; background:linear-gradient(135deg,rgba(16,29,39,.96),rgba(9,14,20,.96)); box-shadow:inset 0 1px rgba(255,255,255,.025); }
.status-line { display:flex; align-items:center; gap:7px; padding:9px 12px; border-bottom:1px solid var(--line); color:var(--muted); font-size:9px; }
.status-line strong { margin-left:auto; color:var(--lime); font-size:9px; }
.pulse,.cloud-dot { width:7px; height:7px; border-radius:50%; background:var(--lime); box-shadow:0 0 10px rgba(173,255,47,.7); }
body[data-enabled="false"] .pulse { background:#ffb84d; box-shadow:0 0 10px rgba(255,184,77,.6); }
body[data-enabled="false"] .status-line strong { color:#ffb84d; }
.switch-row { display:flex; align-items:center; justify-content:space-between; padding:14px 13px; cursor:pointer; }
.switch-row strong,.switch-row small { display:block; }
.switch-row strong { font-size:14px; }
.switch-row small { margin-top:2px; color:var(--muted); font-size:11px; }
.switch { position:relative; width:44px; height:24px; }
.switch input { position:absolute; opacity:0; }
.slider { position:absolute; inset:0; border:1px solid #2b3d49; border-radius:99px; background:#131e26; transition:.2s; }
.slider::after { content:""; position:absolute; width:16px; height:16px; left:3px; top:3px; border-radius:50%; background:#6f8490; transition:.2s; }
.switch input:checked + .slider { border-color:rgba(69,230,255,.6); background:rgba(69,230,255,.12); }
.switch input:checked + .slider::after { transform:translateX(20px); background:var(--cyan); box-shadow:0 0 12px rgba(69,230,255,.7); }
.metric { display:flex; justify-content:space-between; margin-top:12px; padding:11px 12px; border:1px solid var(--line); border-radius:9px; color:var(--muted); font-size:10px; }
.metric strong { color:#dffaff; }
.cloud-line { display:flex; align-items:center; gap:7px; margin:12px 2px 16px; color:#6f8997; font-size:9px; }
.cloud-dot { width:5px; height:5px; background:var(--cyan); box-shadow:0 0 8px rgba(69,230,255,.8); }
button { width:100%; display:flex; justify-content:space-between; align-items:center; border:1px solid #2bc7de; border-radius:8px; padding:11px 13px; background:linear-gradient(90deg,rgba(28,167,190,.2),rgba(69,230,255,.08)); color:var(--cyan); font-size:10px; font-weight:700; cursor:pointer; transition:.18s; }
button:hover { background:rgba(69,230,255,.17); box-shadow:0 0 20px rgba(69,230,255,.1); }
button:focus-visible,input:focus-visible { outline:2px solid var(--cyan); outline-offset:2px; }
+12 -2
View File
@@ -1,2 +1,12 @@
<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>X GeoBlock</title><link rel="stylesheet" href="popup.css"></head>
<body><main><div class="brand"><img src="../icons/icon.png" alt=""><h1>X GeoBlock</h1></div><label><input id="enabled" type="checkbox"> Filtering enabled</label><p id="summary"></p><button id="settings">Open settings</button></main><script src="../lib/config.js"></script><script src="popup.js"></script></body></html>
<!doctype html>
<html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>X GeoBlock</title><link rel="stylesheet" href="popup.css"></head>
<body><main>
<header class="brand"><div class="logo-shell"><img src="../icons/icon.png" alt=""></div><div><p class="eyebrow">NETWORK FILTER</p><h1>X GeoBlock</h1></div><span class="version" id="version">v—</span></header>
<section class="status-card">
<div class="status-line"><span class="pulse" aria-hidden="true"></span><span>FILTER ENGINE</span><strong id="engine-status">ONLINE</strong></div>
<label class="switch-row" for="enabled"><span><strong>Protection</strong><small>Scan posts as they load</small></span><span class="switch"><input id="enabled" type="checkbox"><span class="slider"></span></span></label>
</section>
<div class="metric"><span>BLOCKLIST</span><strong id="summary">—</strong></div>
<div class="cloud-line"><span class="cloud-dot"></span><span>Cloud cache linked</span></div>
<button id="settings"><span>OPEN CONTROL PANEL</span><span aria-hidden="true">→</span></button>
</main><script src="../lib/config.js"></script><script src="popup.js"></script></body></html>
+10 -2
View File
@@ -2,9 +2,17 @@
const extensionApi = globalThis.browser || chrome;
const enabled = document.querySelector("#enabled");
const summary = document.querySelector("#summary");
const engineStatus = document.querySelector("#engine-status");
document.querySelector("#version").textContent = `v${extensionApi.runtime.getManifest().version}`;
extensionApi.storage.sync.get(XGeoConfig.DEFAULT_SETTINGS).then((value) => {
enabled.checked = value.enabled;
summary.textContent = `${value.blacklist.length} ${value.blacklist.length === 1 ? "country" : "countries"} blocked.`;
summary.textContent = `${String(value.blacklist.length).padStart(2, "0")} LOCATIONS`;
engineStatus.textContent = value.enabled ? "ONLINE" : "PAUSED";
document.body.dataset.enabled = String(value.enabled);
});
enabled.addEventListener("change", () => {
extensionApi.storage.sync.set({ enabled: enabled.checked });
engineStatus.textContent = enabled.checked ? "ONLINE" : "PAUSED";
document.body.dataset.enabled = String(enabled.checked);
});
enabled.addEventListener("change", () => extensionApi.storage.sync.set({ enabled: enabled.checked }));
document.querySelector("#settings").addEventListener("click", () => extensionApi.runtime.openOptionsPage());
+11 -1
View File
@@ -1,7 +1,8 @@
const test = require("node:test");
const assert = require("node:assert/strict");
const { findUserRecord } = require("../lib/parser.js");
const { normalizeCountry, isBlacklisted } = require("../lib/config.js");
const config = require("../lib/config.js");
const { normalizeCountry, isBlacklisted } = config;
const { COUNTRIES, LOCATIONS } = require("../lib/countries.js");
const { normalizeEndpoint, hashHandle } = require("../lib/cloud-cache.js");
@@ -27,6 +28,15 @@ test("normalizes country aliases", () => {
assert.equal(isBlacklisted("Russian Federation", ["Russia"]), true);
assert.equal(isBlacklisted("Germany", ["Russia"]), false);
});
test("uses the production collaborative cache endpoint", () => {
assert.equal(config.CLOUD_CACHE_ENDPOINT, "https://x-geoblock-cache.dariosevilla.es");
assert.equal(config.DEFAULT_SETTINGS.cloudCacheEndpoint, config.CLOUD_CACHE_ENDPOINT);
});
test("followed-account exemption is configurable", () => {
assert.equal(config.shouldBlock("Lebanon", ["Lebanon"], true, true), false);
assert.equal(config.shouldBlock("Lebanon", ["Lebanon"], true, false), true);
assert.equal(config.shouldBlock("Lebanon", ["Lebanon"], false, true), true);
});
test("offers the full country checklist with unique values", () => {
assert.equal(COUNTRIES.length, 250);
assert.equal(new Set(COUNTRIES.map((country) => country.code)).size, 250);
+1 -1
View File
@@ -11,7 +11,7 @@ This Cloudflare Worker stores privacy-conscious, consensus-based account locatio
5. Apply migrations: `npm run worker:migrate`.
6. Deploy the code into the Worker: `npm run worker:deploy`.
7. Verify `https://<your-worker>.workers.dev/health` returns `{"ok":true}`.
8. Enter the resulting HTTPS Worker URL in the extension settings.
8. Point `CLOUD_CACHE_ENDPOINT` in `lib/config.js` and the matching manifest host permission at the deployed hostname. Production builds use `https://x-geoblock-cache.dariosevilla.es`.
If you created an empty Worker in the Cloudflare dashboard already, keep the same `name` in `worker/wrangler.toml`; `npm run worker:deploy` replaces its code. You still need a D1 database bound under the exact name `DB`, the migration, and `ABUSE_HMAC_KEY`.