feat: add cross-browser X GeoBlock extension

This commit is contained in:
Darío Sevilla committed 2026-10-15 07:22:51 +00:00
commit 0944faab3e
26 files changed
+803

No files matched your search

+9
View File
@@ -0,0 +1,9 @@
: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; }
h1 { font-size: 32px; margin-bottom: 4px; }.lead,.hint { color: #8b98a5; }.hint { margin: -8px 0 8px; font-size: 14px; }
label:not(.check) { display: block; margin: 24px 0 8px; font-weight: 700; }
textarea,input[type=number] { box-sizing: border-box; width: 100%; border: 1px solid #536471; border-radius: 8px; background: #000; color: inherit; padding: 12px; 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; }
+15
View File
@@ -0,0 +1,15 @@
<!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>
<h1>X GeoBlock</h1><p class="lead">Hide posts based on the country shown in an account's About page.</p>
<form id="settings">
<label class="check"><input id="enabled" type="checkbox"> Enable filtering</label>
<label for="blacklist">Blocked countries</label>
<p class="hint">Enter one country per line, exactly as X displays it.</p>
<textarea id="blacklist" rows="10" spellcheck="false"></textarea>
<label for="ttl">Cache duration (hours)</label><input id="ttl" type="number" min="1" max="8760">
<label class="check"><input id="placeholder" type="checkbox"> Show a clickable placeholder for hidden posts</label>
<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="options.js"></script></body></html>
+33
View File
@@ -0,0 +1,33 @@
"use strict";
const extensionApi = globalThis.browser || chrome;
const form = document.querySelector("#settings");
const enabled = document.querySelector("#enabled");
const blacklist = document.querySelector("#blacklist");
const ttl = document.querySelector("#ttl");
const placeholder = document.querySelector("#placeholder");
const status = document.querySelector("#status");
load();
async function load() {
const value = await extensionApi.storage.sync.get(XGeoConfig.DEFAULT_SETTINGS);
enabled.checked = value.enabled;
blacklist.value = value.blacklist.join("\n");
ttl.value = value.cacheTtlHours;
placeholder.checked = value.showPlaceholder;
}
form.addEventListener("submit", async (event) => {
event.preventDefault();
await extensionApi.storage.sync.set({
enabled: enabled.checked,
blacklist: Array.from(new Set(blacklist.value.split(/\r?\n/).map((value) => value.trim()).filter(Boolean))),
cacheTtlHours: Math.max(1, Number(ttl.value) || 168),
showPlaceholder: placeholder.checked
});
status.textContent = "Settings saved.";
setTimeout(() => status.textContent = "", 2000);
});
document.querySelector("#clear").addEventListener("click", async () => {
await extensionApi.runtime.sendMessage({ type: "clear-cache" });
status.textContent = "User cache cleared.";
setTimeout(() => status.textContent = "", 2000);
});