Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .github/copilot-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ Read README.md first; this file is the short list of things that bite.
- The service worker can die at any time. State lives in `chrome.storage`; `apply.js`
must stay idempotent. All listeners are registered synchronously at top level.
- Settings changes must come from extension pages (`sender.url` is ours). Content scripts
may only send `tokens` and `wall`, neither of which changes settings.
may only send `tokens` and `wall`, neither of which changes settings. The one exception is
the "Nuke this" picker (`nuke:save`, `nuke:undo`, handled in `background/nuke.js`): a save
is accepted only from the top frame of a tab the popup armed, uses the arm up, and every
selector and token is validated in `shared/nuke-rules.js` before it reaches CSS. Keep it that narrow.
- Chrome writes `_metadata/` into a loaded unpacked folder; `package.mjs` skips `_` paths.
- Anything that must happen before a tab-under's redirect (popup opener registration, the
last committed URL) is done synchronously at the top of the listener, before any await.
Expand Down
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,29 @@

## [Unreleased]

## [2.1.0] - 2026-11-16

### Added
- "Nuke this" in the popup: click it, then click anything on the page, and it is hidden,
with scrolling and any blur undone. It stays gone on that site. Clicking inside a
full-screen overlay takes the whole overlay, dimmer included. Esc cancels; the page never
receives the picking click.
- Nuked things that belong to a third-party service (the element's class or id is named
after a script host on the page, like `.pelcro-*` with `js.pelcro.com`) teach SilentBlock
the service, and its overlay is then hidden on every other site that shows it. Shared
platforms (Google, Cloudflare, CDNs and the like) are never learned.
- Undo straight after a nuke from the on-page toast, per site from the popup, and for any
site or service from the new "Nuked" section in Settings.

### Changed
- "Nuke this" replaces "Kill nag wall": pressing it also sweeps the page for anti-adblock
walls as before. "Always on this site" is now "Auto-kill nag walls here".

### Security
- The picker is the only content script that can change settings, and only narrowly: the
service worker accepts a save only from the top frame of a tab the popup just armed, one
save per arm, and validates every selector and token before it reaches any stylesheet.

## [2.0.3] - 2026-10-07

### Changed
Expand Down
5 changes: 3 additions & 2 deletions PRIVACY.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SilentBlock privacy policy

Last updated: 28 September 2026
Last updated: 16 November 2026

**SilentBlock collects nothing.** It has no accounts, no analytics, no telemetry and no
servers. Nothing you browse, block or configure ever leaves your browser.
Expand All @@ -14,7 +14,8 @@ servers. Nothing you browse, block or configure ever leaves your browser.
including Google Safe Browsing or any other lookup service.
- **Reads the pages you visit** in order to hide ads, remove anti-adblock walls and colour
its toolbar icon. What it reads stays in the browser and is not stored.
- **Stores your settings** (paused sites, categories, display options) with your browser's
- **Stores your settings** (paused sites, categories, display options, and the things you
removed with "Nuke this", with the site or service they belong to) with your browser's
extension storage. They stay in that browser. Export them from Settings if you want a copy.
- **Keeps per-tab counts** (how many requests were blocked) in memory for the popup. They are
cleared when you close the tab or the browser.
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ the extension and never downloads rules at runtime.
| **Anti-adblock** | ~8,200 site-specific scriptlets (uBO semantics: `set-constant`, `abort-on-property-read`, `prevent-setTimeout`, `json-prune` and 30 others), run in the page before its own scripts, only on the sites listed. |
| **Pop-ups and tab-unders** | New tabs a page opens are followed for their first few hops and closed if they land on one of ~3,000 `$popup` hosts. A tab sent to an ad right after the page reopened itself in a new tab is put back. |
| **Malware and scams** | uBO Badware, URLhaus, the Phishing URL Blocklist and DurableNapkin's scam list: ~46,000 hosts blocked outright, plus ~36,000 individual phishing and malware page URLs checked on every navigation. A listed page gets a warning with "Back to safety" and "Continue anyway". This layer stays on for paused sites. No API keys and no lookups: every check is local. |
| **Nag walls** | "Kill nag wall" in the popup removes an anti-adblock overlay on demand, or on every visit with "Always on this site". |
| **Nuke this** | Click "Nuke this" in the popup, then click anything on the page: it is hidden, scrolling and blur are undone, and it stays gone on that site. Click inside a full-screen overlay and the whole overlay goes. If the thing was drawn by a third-party service (its class or id is named after a script host on the page, like `.pelcro-*` with `js.pelcro.com`), the service is remembered and its overlay is hidden on every other site that shows it. Big shared platforms (Google, Cloudflare, CDNs) are never learned. Undo from the page, the popup or Settings. |
| **Nag walls** | "Nuke this" also sweeps the page for anti-adblock overlays; "Auto-kill nag walls here" does that on every visit. |

Every piece of CSS is injected as a *user* stylesheet: pages cannot see it, override it or
block it with CSP. On ordinary sites SilentBlock patches no page APIs at all.
Expand Down
7 changes: 5 additions & 2 deletions docs/store-listing.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ WHAT IT BLOCKS
• Malware, phishing and scam sites, using URLhaus, the Phishing URL Blocklist, uBlock Origin's Badware list and a scam blocklist
• "Turn off your ad blocker" walls, with one click, or automatically on sites you choose

NUKE THIS
Something still in your way? Click "Nuke this", click the thing, and it's gone, on that site from now on. If it came from a service lots of sites use, SilentBlock remembers the service and nukes it on those sites too. Changed your mind? Undo is one click.

THE ICON TELLS YOU WHAT HAPPENED
• Blue: nothing on this page needed blocking
• Green: ads and trackers blocked
Expand Down Expand Up @@ -62,8 +65,8 @@ Leave each store's category as the existing listing has it (Firefox: Privacy & S

**Permission justifications:**
- `declarativeNetRequest`: applies the bundled filter lists with the browser's built-in request blocker.
- `scripting`: injects the bundled hiding rules and anti-adblock fixes into pages, and removes anti-adblock walls when the user asks.
- `storage`: saves the user's settings (paused sites, categories, display options).
- `scripting`: injects the bundled hiding rules and anti-adblock fixes into pages, and removes anti-adblock walls and hides page elements the user picks with "Nuke this".
- `storage`: saves the user's settings (paused sites, categories, display options, elements the user chose to hide).
- `webNavigation`: knows when a page loads, to apply site-specific rules, follow new tabs opened by pages (pop-up blocking), and show the malware warning page.
- `webRequest`: read-only, counts blocked requests per tab for the toolbar icon colour and the popup count.
- Host permission `<all_urls>`: ads, trackers and malicious content can appear on any site; blocking and hiding must work on every site the user visits.
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "silentblock",
"version": "2.0.3",
"version": "2.1.0",
"private": true,
"description": "Free, silent ad blocker for Chrome (MV3). No ads, no nags.",
"type": "module",
Expand Down
2 changes: 1 addition & 1 deletion scripts/build.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ for (const cat of categories) {
}

out['content/unwall.js'] = `// Built from src/shared/unwall-core.js. Injected on demand by the popup and on
// per-site "always kill nag walls" hosts. Wrapped so a second injection is harmless.
// per-site "auto-kill nag walls" hosts. Wrapped so a second injection is harmless.
(() => {
${unwallCore}
unwallWatch(15000, () => chrome.runtime.sendMessage({ type: 'wall' }).catch(() => {}));
Expand Down
2 changes: 1 addition & 1 deletion scripts/store-art.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ async function render(dist, iconDir, out) {
window.chrome = {
runtime: {
sendMessage: async (m) => m.type === 'popup:get' ? ${JSON.stringify(popupData)}
: m.type === 'settings:get' ? { state: { enabled: true, allowlist: ['intranet.example.com'], categories: { ads: true, privacy: true, annoyances: true, security: true }, unwallSites: ['recipes.example.com'], badge: false, statusIcon: true }, meta: ${JSON.stringify(meta)} }
: m.type === 'settings:get' ? { state: { enabled: true, allowlist: ['intranet.example.com'], categories: { ads: true, privacy: true, annoyances: true, security: true }, unwallSites: ['recipes.example.com'], nuked: { sites: {}, services: {} }, badge: false, statusIcon: true }, meta: ${JSON.stringify(meta)} }
: {},
openOptionsPage() {},
},
Expand Down
29 changes: 29 additions & 0 deletions src/background/cosmetic.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { hostnameAndParents, shardOf } from '../shared/hostnames.js';
import { loadJSON, getMeta } from './data.js';
import { activeCategories } from './apply.js';
import { isPaused } from './state.js';
import { nukeCss, siteSelectors, serviceTokenIndex, UNLOCK_CSS } from '../shared/nuke-rules.js';

const FLAG = { ghide: 1, ehide: 2, shide: 4, complexException: 8 };

Expand Down Expand Up @@ -76,6 +77,13 @@ export function rememberTop(tabId, hostname) {

export function forgetTab(tabId) {
topHosts.delete(tabId);
nukedServices.delete(tabId);
}

// Learned services that fired on each tab's current page, for the popup.
const nukedServices = new Map();
export function servicesNukedIn(tabId) {
return [...(nukedServices.get(tabId) || [])];
}

async function topHostOf(tabId, fallbackUrl) {
Expand All @@ -96,6 +104,12 @@ export async function onCommitted({ tabId, frameId, documentId, url }, state) {
const top = frameId === 0 ? hostname : await topHostOf(tabId, url);
if (isPaused(top, state)) return;

// "Nuke this" rules are the user's own, so list flags like $elemhide don't switch them off.
if (frameId === 0) {
nukedServices.delete(tabId);
await insert(tabId, frameId, documentId, nukeCss(siteSelectors(state.nuked, hostnameAndParents(hostname))));
}

const flags = await hostFlags(hostname);
if (flags & FLAG.ehide) return;
const meta = await getMeta();
Expand Down Expand Up @@ -131,6 +145,7 @@ export async function onTokens(message, sender, state) {
const hostname = new URL(sender.url).hostname;
const top = await topHostOf(sender.tab.id, sender.tab.url || sender.url);
if (isPaused(top, state)) return;
await nukeServices(message.tokens, sender, state);
const flags = await hostFlags(hostname);
if (flags & (FLAG.ghide | FLAG.ehide)) return;

Expand All @@ -146,3 +161,17 @@ export async function onTokens(message, sender, state) {
}
if (hits.length) await insert(sender.tab.id, sender.frameId, sender.documentId, hideRule(hits));
}

// A page showing a learned service's token gets that token hidden and the page unlocked.
// Tokens are lookup keys; only the copies stored in settings (validated) reach the CSS.
async function nukeServices(reported, sender, state) {
const idx = serviceTokenIndex(state.nuked);
if (!idx.size) return;
const seen = new Set(reported.slice(0, 5000));
const hits = [...idx.keys()].filter((t) => seen.has(t));
if (!hits.length) return;
const set = nukedServices.get(sender.tab.id) || new Set();
for (const t of hits) for (const d of idx.get(t)) set.add(state.nuked.services[d].name);
nukedServices.set(sender.tab.id, set);
await insert(sender.tab.id, sender.frameId, sender.documentId, hideRule(hits) + UNLOCK_CSS);
}
27 changes: 25 additions & 2 deletions src/background/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
// for them. State lives in chrome.storage; nothing here relies on the worker staying alive.
import { loadState, saveState, migrate, allowlistEntryFor, normalise } from './state.js';
import { applyAll, applyAction, desiredContentScripts } from './apply.js';
import { onCommitted, onTokens, rememberTop, forgetTab } from './cosmetic.js';
import { onCommitted, onTokens, rememberTop, forgetTab, servicesNukedIn } from './cosmetic.js';
import { onCreatedNavigationTarget, onTopNavigation, onNavigationError, forgetPopupTab, noteCommitted, lastUrlOf } from './popups.js';
import { resetTab, record, getStatus, levelOf, iconStateFor, forgetStatus } from './status.js';
import { checkNavigation, dangerHost, securityOn, bypass } from './security.js';
import { getMeta } from './data.js';
import { hostnameAndParents, normaliseHostname } from '../shared/hostnames.js';
import { armNuke, onNukeMessage, clearSiteNukes, nukedCount } from './nuke.js';

const EXTENSION_ORIGIN = chrome.runtime.getURL('');

Expand Down Expand Up @@ -101,10 +102,15 @@ chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
const fromExtensionPage = typeof sender.url === 'string' && sender.url.startsWith(EXTENSION_ORIGIN);

// Content scripts may say two things: "these classes/ids are on my page", and
// "I removed a nag wall". Neither changes settings.
// "I removed a nag wall". Neither changes settings. The one exception is the "Nuke this"
// picker, and nuke.js only listens to it in a tab where the popup armed it.
if (!fromExtensionPage && sender.tab) {
if (message.type === 'tokens') loadState().then((s) => onTokens(message, sender, s)).catch(() => {});
if (message.type === 'wall') loadState().then((s) => record(sender.tab.id, 'wall', null, s)).catch(() => {});
if (message.type === 'nuke:save' || message.type === 'nuke:undo') {
onNukeMessage(message, sender).then(sendResponse, (err) => sendResponse({ error: String(err?.message || err) }));
return true;
}
return false;
}

Expand Down Expand Up @@ -132,6 +138,8 @@ async function handle(msg) {
const status = await getStatus(msg.tabId);
out.pausedBy = allowlistEntryFor(info.hostname, state);
out.unwall = hostnameAndParents(info.hostname).some((h) => state.unwallSites.includes(h));
out.nuked = nukedCount(state, info.hostname);
out.nukedServices = servicesNukedIn(msg.tabId);
out.status = { ...status, level: levelOf(status), icon: iconStateFor({ ...status, host: info.hostname }, state) };
}
return out;
Expand All @@ -158,6 +166,21 @@ async function handle(msg) {
return { ok: true, pausedBy: allowlistEntryFor(hostname, state) };
}

case 'nuke:start': {
// Folded-in nag-wall sweep first (harmless where there is no wall), then the picker.
await armNuke(msg.tabId);
await chrome.scripting.executeScript({ target: { tabId: msg.tabId, allFrames: true }, files: ['content/unwall.js'] }).catch(() => {});
await chrome.scripting.executeScript({ target: { tabId: msg.tabId, frameIds: [0] }, files: ['content/nuke.js'] });
return { ok: true };
}

case 'nuke:clearSite': {
const hostname = normaliseHostname(msg.hostname);
if (!hostname) throw new Error('Not a valid hostname');
await clearSiteNukes(hostname);
return { ok: true };
}

case 'unwallNow': {
// Every frame: walls also turn up inside embedded players and sandboxed page frames.
await chrome.scripting.executeScript({ target: { tabId: msg.tabId, allFrames: true }, files: ['content/unwall.js'] });
Expand Down
Loading
Loading