very-good-adblock 0.0.0-stage → 0.3.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,3 +1,63 @@
1
- # Temporary Holding Version
1
+ # very-good-adblock
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Very Good AdBlock's blocking for apps that embed WebKit (`WKWebView`) instead of running a browser
4
+ extension. The extension's own rules ship as WebKit content-blocker lists and its content scripts
5
+ as user scripts, so an app and the extension stay one blocker. Built by the Stacks `webkit`
6
+ extension target.
7
+
8
+ ## Install
9
+
10
+ ```sh
11
+ bun add very-good-adblock
12
+ ```
13
+
14
+ ## Use
15
+
16
+ ```ts
17
+ import { webkitRuleLists, webkitUserScripts } from 'very-good-adblock'
18
+
19
+ // Compile each list once with WKContentRuleListStore, under its id.
20
+ // Reuse the compiled copy until `version` changes.
21
+ for (const list of await webkitRuleLists())
22
+ compile(list.id, list.version, list.json)
23
+
24
+ // Inject each script as a WKUserScript: `world` 'page' is WKContentWorld.page,
25
+ // 'isolated' a content world of your own; `runAt` is document-start or document-end.
26
+ for (const script of webkitUserScripts())
27
+ inject(script)
28
+ ```
29
+
30
+ - `webkitRuleLists({ includeDisabled })` returns the enabled lists: the network rules and the
31
+ default cosmetic hiding. `includeDisabled` adds the opt-in lists (`enabled: false`): the broader
32
+ cosmetic selectors and cookie-banner hiding.
33
+ - `webkitUserScripts()` returns the YouTube and X pruning scripts and the pop-up guard (page world)
34
+ and the content script (isolated world), with the match patterns each one runs on.
35
+ - `webkitManifest()` is the whole build manifest, including the conversion report. The extension's
36
+ three redirect-to-stub rules have no content-blocker form and are listed there.
37
+
38
+ The raw files are exported too: `very-good-adblock/webkit/manifest.json`,
39
+ `very-good-adblock/webkit/lists/<id>.json`, `very-good-adblock/webkit/scripts/<id>.js`.
40
+
41
+ ## The content script's messages
42
+
43
+ The isolated-world `content` script calls `chrome.runtime.sendMessage`, which arrives at the
44
+ `very-good-adblock` script message handler (`webkit.messageHandlers['very-good-adblock']`) as
45
+ `{ v: 1, api: 'runtime.sendMessage', payload: { message } }`. Register the handler with
46
+ `WKScriptMessageHandlerWithReply`. The messages are:
47
+
48
+ | `message.type` | Reply |
49
+ |---|---|
50
+ | `get-dashboard` | `{ ok: true, data: { settings } }`, or nothing to use the default settings |
51
+ | `record-blocks` | nothing (block events for statistics) |
52
+ | `record-cosmetic` | nothing (hidden-element counts for statistics) |
53
+
54
+ Without a handler the script runs with the default settings. The full contract is in the Stacks
55
+ `stacks-browser-extension` skill (`WEBKIT.md`).
56
+
57
+ The rules are generated from the extension's source in
58
+ [chrisbbreuer/very-good-adblock](https://github.com/chrisbbreuer/very-good-adblock), and versions
59
+ follow the extension's.
60
+
61
+ ## License
62
+
63
+ MIT
@@ -0,0 +1,2 @@
1
+ // Generated by `buddy generate:entries` for very-good-adblock. Do not edit.
2
+ export * from './webkit';
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ export*from"./webkit.js";
@@ -0,0 +1 @@
1
+ [{"trigger":{"url-filter":".*"},"action":{"type":"css-display-none","selector":"ins.adsbygoogle, [id^=\"google_ads_iframe_\"], [id^=\"div-gpt-ad\"], [data-google-query-id], [aria-label=\"Advertisement\"], amp-ad, [id^=\"taboola-\"], iframe[src*=\"googleads.g.doubleclick.net\"], [id^=\"sdgSlotContainer-\"], [id^=\"sdgSlotHull-\"], [id^=\"sdgAdServerAnchor-\"], [id^=\"sdgLoadingSpinner-\"], .sdgSlotContainer, .sdgSlotHull, .sdgAdServerAnchor, .sdgSpinner, .ad-placement-note, div.werbung, div.anzeige, [class*=\"werbung-\"], [id^=\"werbung\"]"}},{"trigger":{"url-filter":".*","if-domain":["*youtube.com","*youtube-nocookie.com"]},"action":{"type":"css-display-none","selector":"#masthead-ad, #player-ads, ytd-ad-slot-renderer, ytd-in-feed-ad-layout-renderer, ytd-rich-item-renderer:has(ytd-ad-slot-renderer), ytd-rich-item-renderer:has(ytd-in-feed-ad-layout-renderer), ytd-display-ad-renderer, ytd-promoted-sparkles-web-renderer, ytd-promoted-sparkles-text-search-renderer, ytd-promoted-video-renderer, ytd-compact-promoted-video-renderer, ytd-companion-slot-renderer, ytd-action-companion-ad-renderer, ytd-player-legacy-desktop-watch-ads-renderer, ytd-statement-banner-renderer, ytd-brand-video-shelf-renderer, ytd-brand-video-singleton-renderer, ytd-search-pyv-renderer, ytd-enforcement-message-view-model, ytd-enforcement-message-renderer, ytd-popup-container:has(ytd-enforcement-message-view-model)"}},{"trigger":{"url-filter":".*","if-domain":["*twitch.tv"]},"action":{"type":"css-display-none","selector":"button[aria-label=\"Leave feedback for this Ad\"], button[aria-label=\"Learn more about this ad\"], .video-player__overlay .player-overlay-background:has(a[href*=\"how-to-allow-ads-browser\"]), .video-player__overlay .player-overlay-background:has(a[href=\"https://www.twitch.tv/turbo\"])"}}]
@@ -0,0 +1 @@
1
+ [{"trigger":{"url-filter":".*"},"action":{"type":"css-display-none","selector":"[id*=\"ad-container\"], [class*=\"ad-container\"], iframe[src*=\"/ads/\"], [data-ad-slot], [data-ad-unit], [id^=\"ad-position-\"], #superbanner, [id^=\"banner_btf\"]"}},{"trigger":{"url-filter":".*","if-domain":["*youtube.com","*youtube-nocookie.com"]},"action":{"type":"css-display-none","selector":"ytd-rich-section-renderer:has(ytd-statement-banner-renderer), ytd-reel-shelf-renderer:has(ytd-ad-slot-renderer), .ytp-ad-overlay-slot, ytd-merch-shelf-renderer"}},{"trigger":{"url-filter":".*","if-domain":["*twitch.tv"]},"action":{"type":"css-display-none","selector":".video-player__overlay .player-overlay-background--darkness-3"}},{"trigger":{"url-filter":".*","if-domain":["*x.com","*twitter.com"]},"action":{"type":"css-display-none","selector":"div[data-testid=\"trend\"]:has([data-testid=\"promotedIndicator\"])"}}]
@@ -0,0 +1 @@
1
+ [{"trigger":{"url-filter":".*"},"action":{"type":"css-display-none","selector":"#onetrust-consent-sdk, #onetrust-banner-sdk, #didomi-host, .didomi-consent-popup, #CybotCookiebotDialog, #CybotCookiebotDialogBodyUnderlay, #usercentrics-root, #usercentrics-cmp-ui, .fc-consent-root, .qc-cmp2-container, .qc-cmp-cleanslate, #truste-consent-track, .truste_overlay, .truste_box_overlay, .sp_message_container, [id^=\"sp_message_container_\"], .osano-cm-window, #cookiescript_injected, #cmplz-cookiebanner-container, .cmplz-cookiebanner, #BorlabsCookieBox, .cky-consent-container, .cky-overlay, #cookie-law-info-bar, .cc-window.cc-banner, #gdpr-consent-tool-wrapper, #termly-code-snippet-support"}}]