From 8477e527a602d87dbd333d35c5a9ef51ceac1034 Mon Sep 17 00:00:00 2001 From: Stanislav A Date: Mon, 5 Jun 2023 16:24:33 +0300 Subject: [PATCH] lint markdown --- src/scriptlets/remove-node-text.js | 26 +- src/scriptlets/trusted-replace-node-text.js | 26 +- wiki/about-redirects.md | 580 +++++-- wiki/about-scriptlets.md | 1678 ++++++++++++------- wiki/about-trusted-scriptlets.md | 563 ++++--- wiki/compatibility-table.md | 17 +- 6 files changed, 1888 insertions(+), 1002 deletions(-) diff --git a/src/scriptlets/remove-node-text.js b/src/scriptlets/remove-node-text.js index b37d006f..47d99c47 100644 --- a/src/scriptlets/remove-node-text.js +++ b/src/scriptlets/remove-node-text.js @@ -23,19 +23,22 @@ import { * Related UBO scriptlet: * https://github.com/gorhill/uBlock/commit/2bb446797a12086f2eebc0c8635b671b8b90c477 * - * **Syntax** - * ``` + * ### Syntax + * + * ```adblock * example.org#%#//scriptlet('remove-node-text', nodeName, condition) * ``` * - * - `nodeName` — required, string or RegExp, specifies DOM node name from which the text will be removed. Must target lowercased node names, - * e.g `div` instead of `DIV`. - * - `textMatch` — required, string or RegExp to match against node's text content. If matched, the whole text will be removed. - * Case sensitive. + * - `nodeName` — required, string or RegExp, specifies DOM node name from which the text will be removed. + * Must target lowercased node names, e.g `div` instead of `DIV`. + * - `textMatch` — required, string or RegExp to match against node's text content. + * If matched, the whole text will be removed. Case sensitive. * - * **Examples** - * 1. Remove node's text content: - * ``` + * ### Examples + * + * 1. Remove node's text content: + * + * ```adblock * example.org#%#//scriptlet('remove-node-text', 'div', 'some text') * ``` * @@ -49,8 +52,9 @@ import { * some text * ``` * - * 2. Remove node's text content, matching both node name and condition by RegExp: - * ``` + * 2. Remove node's text content, matching both node name and condition by RegExp: + * + * ```adblock * example.org#%#//scriptlet('remove-node-text', '/[a-z]*[0-9]/', '/text/') * ``` * diff --git a/src/scriptlets/trusted-replace-node-text.js b/src/scriptlets/trusted-replace-node-text.js index 1e7f081e..c4ee7fed 100644 --- a/src/scriptlets/trusted-replace-node-text.js +++ b/src/scriptlets/trusted-replace-node-text.js @@ -23,21 +23,24 @@ import { * Related UBO scriptlet: * https://github.com/gorhill/uBlock/commit/41876336db48 * - * **Syntax** - * ``` + * ### Syntax + * + * ```adblock * example.org#%#//scriptlet('trusted-replace-node-text', nodeName, condition) * ``` * - * - `nodeName` — required, string or RegExp, specifies DOM node name from which the text will be removed. Must target lowercased node names, - * e.g `div` instead of `DIV`. - * - `textMatch` — required, string or RegExp to match against node's text content. If matched, the whole text will be removed. - * Case sensitive. + * - `nodeName` — required, string or RegExp, specifies DOM node name from which the text will be removed. + * Must target lowercased node names, e.g `div` instead of `DIV`. + * - `textMatch` — required, string or RegExp to match against node's text content. + * If matched, the whole text will be removed. Case sensitive. * - `pattern` — required, string or regexp for matching contents of `node.textContent` that should be replaced. * - `replacement` — required, string to replace text content matched by `pattern`. * - * **Examples** - * 1. Replace node's text content: - * ``` + * ### Examples + * + * 1. Replace node's text content: + * + * ```adblock * example.org#%#//scriptlet('trusted-replace-node-text', 'div', 'some', 'text', 'other text') * ``` * @@ -53,8 +56,9 @@ import { * some text * ``` * - * 2. Replace node's text content, matching both node name, text and pattern by RegExp: - * ``` + * 2. Replace node's text content, matching both node name, text and pattern by RegExp: + * + * ```adblock * example.org#%#//scriptlet('trusted-replace-node-text', '/[a-z]*[0-9]/', '/s\dme/', '/t\dxt/', 'other text') * ``` * diff --git a/wiki/about-redirects.md b/wiki/about-redirects.md index e446ff98..e015ecc4 100644 --- a/wiki/about-redirects.md +++ b/wiki/about-redirects.md @@ -1,227 +1,341 @@ -## Available Redirect resources -* [1x1-transparent.gif](#1x1-transparent.gif) -* [2x2-transparent.png](#2x2-transparent.png) -* [3x2-transparent.png](#3x2-transparent.png) -* [32x32-transparent.png](#32x32-transparent.png) -* [noopframe](#noopframe) -* [noopcss](#noopcss) -* [noopjs](#noopjs) -* [noopjson](#noopjson) -* [nooptext](#nooptext) -* [empty](#empty) -* [noopvmap-1.0](#noopvmap-1.0) -* [noopvast-2.0](#noopvast-2.0) -* [noopvast-3.0](#noopvast-3.0) -* [noopvast-4.0](#noopvast-4.0) -* [noopmp3-0.1s](#noopmp3-0.1s) -* [noopmp4-1s](#noopmp4-1s) -* [amazon-apstag](#amazon-apstag) -* [ati-smarttag](#ati-smarttag) -* [didomi-loader](#didomi-loader) -* [fingerprintjs2](#fingerprintjs2) -* [fingerprintjs3](#fingerprintjs3) -* [gemius](#gemius) -* [google-analytics-ga](#google-analytics-ga) -* [google-analytics](#google-analytics) -* [google-ima3](#google-ima3) -* [googlesyndication-adsbygoogle](#googlesyndication-adsbygoogle) -* [googletagservices-gpt](#googletagservices-gpt) -* [matomo](#matomo) -* [metrika-yandex-tag](#metrika-yandex-tag) -* [metrika-yandex-watch](#metrika-yandex-watch) -* [naver-wcslog](#naver-wcslog) -* [noeval](#noeval) -* [pardot-1.0](#pardot-1.0) -* [prebid-ads](#prebid-ads) -* [prebid](#prebid) -* [prevent-bab](#prevent-bab) -* [prevent-bab2](#prevent-bab2) -* [prevent-fab-3.2.0](#prevent-fab-3.2.0) -* [prevent-popads-net](#prevent-popads-net) -* [scorecardresearch-beacon](#scorecardresearch-beacon) -* [set-popads-dummy](#set-popads-dummy) -* [click2load.html](#click2load.html) -* * * -### ⚡️ 1x1-transparent.gif -**Example** -``` +# Available Redirect resources + +- [1x1-transparent.gif](#1x1-transparent.gif) +- [2x2-transparent.png](#2x2-transparent.png) +- [3x2-transparent.png](#3x2-transparent.png) +- [32x32-transparent.png](#32x32-transparent.png) +- [noopframe](#noopframe) +- [noopcss](#noopcss) +- [noopjs](#noopjs) +- [noopjson](#noopjson) +- [nooptext](#nooptext) +- [empty](#empty) +- [noopvmap-1.0](#noopvmap-1.0) +- [noopvast-2.0](#noopvast-2.0) +- [noopvast-3.0](#noopvast-3.0) +- [noopvast-4.0](#noopvast-4.0) +- [noopmp3-0.1s](#noopmp3-0.1s) +- [noopmp4-1s](#noopmp4-1s) +- [amazon-apstag](#amazon-apstag) +- [ati-smarttag](#ati-smarttag) +- [didomi-loader](#didomi-loader) +- [fingerprintjs2](#fingerprintjs2) +- [fingerprintjs3](#fingerprintjs3) +- [gemius](#gemius) +- [google-analytics-ga](#google-analytics-ga) +- [google-analytics](#google-analytics) +- [google-ima3](#google-ima3) +- [googlesyndication-adsbygoogle](#googlesyndication-adsbygoogle) +- [googletagservices-gpt](#googletagservices-gpt) +- [matomo](#matomo) +- [metrika-yandex-tag](#metrika-yandex-tag) +- [metrika-yandex-watch](#metrika-yandex-watch) +- [naver-wcslog](#naver-wcslog) +- [noeval](#noeval) +- [pardot-1.0](#pardot-1.0) +- [prebid-ads](#prebid-ads) +- [prebid](#prebid) +- [prevent-bab](#prevent-bab) +- [prevent-bab2](#prevent-bab2) +- [prevent-fab-3.2.0](#prevent-fab-3.2.0) +- [prevent-popads-net](#prevent-popads-net) +- [scorecardresearch-beacon](#scorecardresearch-beacon) +- [set-popads-dummy](#set-popads-dummy) +- [click2load.html](#click2load.html) + +* * * + +## ⚡️ 1x1-transparent.gif + +> Added in v1.0.4. + +### Examples + +```adblock ||example.org^$image,redirect=1x1-transparent.gif ``` + [Redirect source](../src/redirects/static-redirects.yml) + * * * -### ⚡️ 2x2-transparent.png -**Example** -``` +## ⚡️ 2x2-transparent.png + +> Added in v1.0.4. + +### Examples + +```adblock ||example.org^$image,redirect=2x2-transparent.png ``` + [Redirect source](../src/redirects/static-redirects.yml) + * * * -### ⚡️ 3x2-transparent.png -**Example** -``` +## ⚡️ 3x2-transparent.png + +> Added in v1.0.4. + +### Examples + +```adblock ||example.org^$image,redirect=3x2-transparent.png ``` + [Redirect source](../src/redirects/static-redirects.yml) + * * * -### ⚡️ 32x32-transparent.png -**Example** -``` +## ⚡️ 32x32-transparent.png + +> Added in v1.0.4. + +### Examples + +```adblock ||example.org^$image,redirect=32x32-transparent.png ``` + [Redirect source](../src/redirects/static-redirects.yml) + * * * -### ⚡️ noopframe -**Example** -``` +## ⚡️ noopframe + +> Added in v1.0.4. + +### Examples + +```adblock ||example.com^$subdocument,redirect=noopframe,domain=example.org ``` + [Redirect source](../src/redirects/static-redirects.yml) + * * * -### ⚡️ noopcss -**Example** -``` +## ⚡️ noopcss + +> Added in v1.0.4. + +### Examples + +```adblock ||example.org/style.css$stylesheet,redirect=noopcss ``` + [Redirect source](../src/redirects/static-redirects.yml) + * * * -### ⚡️ noopjs -**Example** -``` +## ⚡️ noopjs + +> Added in v1.0.4. + +### Examples + +```adblock ||example.org/advert.js$script,redirect=noopjs ``` + [Redirect source](../src/redirects/static-redirects.yml) + * * * -### ⚡️ noopjson -**Example** -``` +## ⚡️ noopjson + +> Added in v1.6.2. + +### Examples + +```adblock ||example.org/geo/location$xmlhttprequest,redirect=noopjson ``` + [Redirect source](../src/redirects/static-redirects.yml) + * * * -### ⚡️ nooptext -**Example** -``` +## ⚡️ nooptext + +> Added in v1.0.4. + +### Examples + +```adblock ||example.org/advert.js$xmlhttprequest,redirect=nooptext ``` + [Redirect source](../src/redirects/static-redirects.yml) + * * * -### ⚡️ empty -Pretty much the same as `nooptext`. Used for conversion of modifier `empty` so better avoid its using in production filter lists. +## ⚡️ empty -**Example** -``` +> Added in v1.3.9. + +Pretty much the same as `nooptext`. Used for conversion of modifier `empty` +so better avoid its using in prod versions of filter lists. + +### Examples + +```adblock ||example.org/log$redirect=empty ``` + [Redirect source](../src/redirects/static-redirects.yml) + * * * -### ⚡️ noopvmap-1.0 +## ⚡️ noopvmap-1.0 + +> Added in v1.1.5. + Redirects request to an empty VMAP response. -**Example** -``` +### Examples + +```adblock ||example.org/vmap01.xml$xmlhttprequest,redirect=noopvmap-1.0 ``` + [Redirect source](../src/redirects/static-redirects.yml) + * * * -### ⚡️ noopvast-2.0 +## ⚡️ noopvast-2.0 + +> Added in v1.0.10. + Redirects request to an empty VAST 2.0 response. -**Example** -``` +### Examples + +```adblock ||example.org/vast02.xml^$xmlhttprequest,redirect=noopvast-2.0 ``` + [Redirect source](../src/redirects/static-redirects.yml) + * * * -### ⚡️ noopvast-3.0 +## ⚡️ noopvast-3.0 + +> Added in v1.0.10. + Redirects request to an empty VAST 3.0 response. -**Example** -``` +### Examples + +```adblock ||example.org/vast03.xml^$xmlhttprequest,redirect=noopvast-3.0 ``` + [Redirect source](../src/redirects/static-redirects.yml) + * * * -### ⚡️ noopvast-4.0 +## ⚡️ noopvast-4.0 + +> Added in v1.4.3. + Redirects request to an empty VAST 4.0 response. -**Example** -``` +### Examples + +```adblock ||example.org/vast04.xml^$xmlhttprequest,redirect=noopvast-4.0 ``` + [Redirect source](../src/redirects/static-redirects.yml) + * * * -### ⚡️ noopmp3-0.1s -**Example** -``` +## ⚡️ noopmp3-0.1s + +> Added in v1.0.4. + +### Examples + +```adblock ||example.org/advert.mp3$media,redirect=noopmp3-0.1s ``` + [Redirect source](../src/redirects/static-redirects.yml) + * * * -### ⚡️ noopmp4-1s -**Example** -``` +## ⚡️ noopmp4-1s + +> Added in v1.0.4. + +### Examples + +```adblock ||example.org/advert.mp4$media,redirect=noopmp4-1s ``` + [Redirect source](../src/redirects/static-redirects.yml) + * * * -### ⚡️ amazon-apstag +## ⚡️ amazon-apstag + +> Added in v1.2.3. Mocks Amazon's apstag.js Related UBO redirect resource: -https://github.com/gorhill/uBlock/blob/f842ab6d3c1cf0394f95d27092bf59627262da40/src/web_accessible_resources/amazon_apstag.js +https://github.com/gorhill/uBlock/blob/master/src/web_accessible_resources/amazon_apstag.js -**Example** -``` +### Examples + +```adblock ||amazon-adsystem.com/aax2/apstag.js$script,redirect=amazon-apstag ``` [Redirect source](../src/redirects/amazon-apstag.js) + * * * -### ⚡️ ati-smarttag +## ⚡️ ati-smarttag + +> Added in v1.5.0. Mocks AT Internat SmartTag. https://developers.atinternet-solutions.com/as2-tagging-en/javascript-en/getting-started-javascript-en/tracker-initialisation-javascript-en/ -**Example** -``` -||bloctel.gouv.fr/assets/scripts/smarttag.js$script,redirect=ati-smarttag +### Examples + +```adblock +||example.com/assets/scripts/smarttag.js$script,redirect=ati-smarttag ``` [Redirect source](../src/redirects/ati-smarttag.js) + * * * -### ⚡️ didomi-loader +## ⚡️ didomi-loader + +> Added in v1.6.2. Mocks Didomi's CMP loader script. https://developers.didomi.io/ -**Example** -``` +### Examples + +```adblock ||sdk.privacy-center.org/fbf86806f86e/loader.js$script,redirect=didomi-loader ``` [Redirect source](../src/redirects/didomi-loader.js) + * * * -### ⚡️ fingerprintjs2 +## ⚡️ fingerprintjs2 + +> Added in v1.5.0. Mocks FingerprintJS v2 https://github.com/fingerprintjs @@ -229,15 +343,19 @@ https://github.com/fingerprintjs Related UBO redirect resource: https://github.com/gorhill/uBlock/blob/master/src/web_accessible_resources/fingerprint2.js -**Example** -``` -||the-japan-news.com/modules/js/lib/fgp/fingerprint2.js$script,redirect=fingerprintjs2 +### Examples + +```adblock +||example.com/modules/js/lib/fgp/fingerprint2.js$script,redirect=fingerprintjs2 ``` [Redirect source](../src/redirects/fingerprintjs2.js) + * * * -### ⚡️ fingerprintjs3 +## ⚡️ fingerprintjs3 + +> Added in v1.6.2. Mocks FingerprintJS v3 https://github.com/fingerprintjs @@ -245,152 +363,197 @@ https://github.com/fingerprintjs Related UBO redirect resource: https://github.com/gorhill/uBlock/blob/master/src/web_accessible_resources/fingerprint3.js -**Example** -``` -||sephora.com/js/ufe/isomorphic/thirdparty/fp.min.js$script,redirect=fingerprintjs3 +### Examples + +```adblock +||example.com/js/ufe/isomorphic/thirdparty/fp.min.js$script,redirect=fingerprintjs3 ``` [Redirect source](../src/redirects/fingerprintjs3.js) + * * * -### ⚡️ gemius +## ⚡️ gemius + +> Added in v1.5.0. Mocks Gemius Analytics. https://flowplayer.com/developers/plugins/gemius -**Example** -``` -||gapt.hit.gemius.pl/gplayer.js$script,redirect=gemius +### Examples + +```adblock +||example.org/gplayer.js$script,redirect=gemius ``` [Redirect source](../src/redirects/gemius.js) + * * * -### ⚡️ google-analytics-ga +## ⚡️ google-analytics-ga + +> Added in v1.0.10. Mocks old Google Analytics API. Related UBO redirect resource: -https://github.com/gorhill/uBlock/blob/a94df7f3b27080ae2dcb3b914ace39c0c294d2f6/src/web_accessible_resources/google-analytics_ga.js +https://github.com/gorhill/uBlock/blob/master/src/web_accessible_resources/google-analytics_ga.js -**Example** -``` +### Examples + +```adblock ||google-analytics.com/ga.js$script,redirect=google-analytics-ga ``` [Redirect source](../src/redirects/google-analytics-ga.js) + * * * -### ⚡️ google-analytics +## ⚡️ google-analytics + +> Added in v1.0.10. Mocks Google's Analytics and Tag Manager APIs. -[Covers obsolete googletagmanager-gtm redirect functionality](https://github.com/AdguardTeam/Scriptlets/issues/127). +Covers functionality of +the [obsolete googletagmanager-gtm redirect](https://github.com/AdguardTeam/Scriptlets/issues/127). Related UBO redirect resource: -https://github.com/gorhill/uBlock/blob/8cd2a1d263a96421487b39040c1d23eb01169484/src/web_accessible_resources/google-analytics_analytics.js +https://github.com/gorhill/uBlock/blob/master/src/web_accessible_resources/google-analytics_analytics.js -**Example** -``` +### Examples + +```adblock ||google-analytics.com/analytics.js$script,redirect=google-analytics -||googletagmanager.com/gtm.js$script,redirect=googletagmanager-gtm +||googletagmanager.com/gtm.js$script,redirect=google-analytics ``` [Redirect source](../src/redirects/google-analytics.js) + * * * -### ⚡️ google-ima3 +## ⚡️ google-ima3 + +> Added in v1.6.2. Mocks the IMA SDK of Google. -**Example** -``` +### Examples + +```adblock ||imasdk.googleapis.com/js/sdkloader/ima3.js$script,redirect=google-ima3 ``` [Redirect source](../src/redirects/google-ima3.js) + * * * -### ⚡️ googlesyndication-adsbygoogle +## ⚡️ googlesyndication-adsbygoogle + +> Added in v1.0.10. Mocks Google AdSense API. Related UBO redirect resource: -https://github.com/gorhill/uBlock/blob/a94df7f3b27080ae2dcb3b914ace39c0c294d2f6/src/web_accessible_resources/googlesyndication_adsbygoogle.js +https://github.com/gorhill/uBlock/blob/master/src/web_accessible_resources/googlesyndication_adsbygoogle.js -**Example** -``` +### Examples + +```adblock ||pagead2.googlesyndication.com/pagead/js/adsbygoogle.js$script,redirect=googlesyndication-adsbygoogle ``` [Redirect source](../src/redirects/googlesyndication-adsbygoogle.js) + * * * -### ⚡️ googletagservices-gpt +## ⚡️ googletagservices-gpt + +> Added in v1.0.10. Mocks Google Publisher Tag API. Related UBO redirect resource: -https://github.com/gorhill/uBlock/blob/a94df7f3b27080ae2dcb3b914ace39c0c294d2f6/src/web_accessible_resources/googletagservices_gpt.js +https://github.com/gorhill/uBlock/blob/master/src/web_accessible_resources/googletagservices_gpt.js -**Example** -``` +### Examples + +```adblock ||googletagservices.com/tag/js/gpt.js$script,redirect=googletagservices-gpt ``` [Redirect source](../src/redirects/googletagservices-gpt.js) + * * * -### ⚡️ matomo +## ⚡️ matomo + +> Added in v1.5.0. Mocks the piwik.js file of Matomo (formerly Piwik). -**Example** -``` +### Examples + +```adblock ||example.org/piwik.js$script,redirect=matomo ``` [Redirect source](../src/redirects/matomo.js) + * * * -### ⚡️ metrika-yandex-tag +## ⚡️ metrika-yandex-tag + +> Added in v1.0.10. Mocks Yandex Metrika API. https://yandex.ru/support/metrica/objects/method-reference.html -**Example** -``` +### Examples + +```adblock ||mc.yandex.ru/metrika/tag.js$script,redirect=metrika-yandex-tag ``` [Redirect source](../src/redirects/metrika-yandex-tag.js) + * * * -### ⚡️ metrika-yandex-watch +## ⚡️ metrika-yandex-watch + +> Added in v1.0.10. Mocks the old Yandex Metrika API. https://yandex.ru/support/metrica/objects/_method-reference.html -**Example** -``` +### Examples + +```adblock ||mc.yandex.ru/metrika/watch.js$script,redirect=metrika-yandex-watch ``` [Redirect source](../src/redirects/metrika-yandex-watch.js) + * * * -### ⚡️ naver-wcslog +## ⚡️ naver-wcslog + +> Added in v1.6.2. Mocks wcslog.js of Naver Analytics. -**Example** -``` +### Examples + +```adblock ||wcs.naver.net/wcslog.js$script,redirect=naver-wcslog ``` [Redirect source](../src/redirects/naver-wcslog.js) + * * * -### ⚡️ noeval +## ⚡️ noeval + +> Added in v1.0.4. Redirects request to the source which sets static properties to PopAds and popns objects. @@ -403,57 +566,74 @@ See [scriptlet description](../wiki/about-scriptlets.md#noeval). Related UBO redirect resource: https://github.com/gorhill/uBlock/wiki/Resources-Library#noeval-silentjs- -**Example** -``` +### Examples + +```adblock ||example.org/index.js$script,redirect=noeval ``` [Redirect source](../src/redirects/noeval.js) + * * * -### ⚡️ pardot-1.0 +## ⚡️ pardot-1.0 + +> Added in v1.6.55. Mocks the pd.js file of Salesforce. https://pi.pardot.com/pd.js https://developer.salesforce.com/docs/marketing/pardot/overview -**Example** -``` +### Examples + +```adblock ||pi.pardot.com/pd.js$script,redirect=pardot ||pacedg.com.au/pd.js$redirect=pardot ``` [Redirect source](../src/redirects/pardot-1.0.js) + * * * -### ⚡️ prebid-ads +## ⚡️ prebid-ads + +> Added in v1.6.2. Sets predefined constants on a page: + - `canRunAds`: `true` - `isAdBlockActive`: `false` -**Example** -``` -||playerdrive.me/assets/js/prebid-ads.js$script,redirect=prebid-ads +### Examples + +```adblock +||example.org/assets/js/prebid-ads.js$script,redirect=prebid-ads ``` [Redirect source](../src/redirects/prebid-ads.js) + * * * -### ⚡️ prebid +## ⚡️ prebid + +> Added in v1.6.2. Mocks the prebid.js header bidding suit. https://docs.prebid.org/ -**Example** -``` -||tmgrup.com.tr/bd/hb/prebid.js$script,redirect=prebid +### Examples + +```adblock +||example.org/bd/hb/prebid.js$script,redirect=prebid ``` [Redirect source](../src/redirects/prebid.js) + * * * -### ⚡️ prevent-bab +## ⚡️ prevent-bab + +> Added in v1.3.19. Prevents BlockAdblock script from detecting an ad blocker. @@ -461,17 +641,21 @@ Mostly it is used as `scriptlet`. See [scriptlet description](../wiki/about-scriptlets.md#prevent-bab). Related UBO redirect resource: -https://github.com/gorhill/uBlock/blob/a94df7f3b27080ae2dcb3b914ace39c0c294d2f6/src/web_accessible_resources/nobab.js +https://github.com/gorhill/uBlock/blob/master/src/web_accessible_resources/nobab.js -**Example** -``` +### Examples + +```adblock /blockadblock.$script,redirect=prevent-bab ``` [Redirect source](../src/redirects/prevent-bab.js) + * * * -### ⚡️ prevent-bab2 +## ⚡️ prevent-bab2 + +> Added in v1.5.0. Prevents BlockAdblock script from detecting an ad blocker. @@ -480,75 +664,99 @@ https://github.com/gorhill/uBlock/blob/master/src/web_accessible_resources/nobab See [redirect description](../wiki/about-redirects.md#prevent-bab2). -**Syntax** -``` +### Examples + +```adblock /blockadblock.$script,redirect=prevent-bab2 ``` [Redirect source](../src/redirects/prevent-bab2.js) + * * * -### ⚡️ prevent-fab-3.2.0 +## ⚡️ prevent-fab-3.2.0 + +> Added in v1.0.4. Redirects fuckadblock script to the source js file. -**Example** -``` +### Examples + +```adblock \*\/fuckadblock-$script,redirect=prevent-fab-3.2.0 ``` [Redirect source](../src/redirects/prevent-fab-3.2.0.js) + * * * -### ⚡️ prevent-popads-net +## ⚡️ prevent-popads-net + +> Added in v1.0.4. Redirects request to the source which sets static properties to PopAds and popns objects. -**Example** -``` +### Examples + +```adblock ||popads.net/pop.js$script,redirect=prevent-popads-net ``` [Redirect source](../src/redirects/prevent-popads-net.js) + * * * -### ⚡️ scorecardresearch-beacon +## ⚡️ scorecardresearch-beacon + +> Added in v1.0.10. Mocks Scorecard Research API. Related UBO redirect resource: -https://github.com/gorhill/uBlock/blob/a94df7f3b27080ae2dcb3b914ace39c0c294d2f6/src/web_accessible_resources/scorecardresearch_beacon.js +https://github.com/gorhill/uBlock/blob/master/src/web_accessible_resources/scorecardresearch_beacon.js -**Example** -``` +### Examples + +```adblock ||sb.scorecardresearch.com/beacon.js$script,redirect=scorecardresearch-beacon ``` [Redirect source](../src/redirects/scorecardresearch-beacon.js) + * * * -### ⚡️ set-popads-dummy +## ⚡️ set-popads-dummy + +> Added in v1.0.4. Redirects request to the source which sets static properties to PopAds and popns objects. -**Example** -``` +### Examples + +```adblock ||popads.net^$script,redirect=set-popads-dummy,domain=example.org ``` [Redirect source](../src/redirects/set-popads-dummy.js) + * * * -### ⚡️ click2load.html +## ⚡️ click2load.html + +> Added in v1.5.0. + Redirects resource and replaces supposed content by decoy frame with button for original content recovering Related UBO redirect resource: https://github.com/gorhill/uBlock/blob/1.31.0/src/web_accessible_resources/click2load.html -**Example** -``` +### Example + +```adblock ||youtube.com/embed/$frame,third-party,redirect=click2load.html ``` + [Redirect source](../src/redirects/blocking-redirects/click2load.html) + * * * diff --git a/wiki/about-scriptlets.md b/wiki/about-scriptlets.md index 68739512..72cddf89 100644 --- a/wiki/about-scriptlets.md +++ b/wiki/about-scriptlets.md @@ -1,55 +1,62 @@ -## Available Scriptlets -* [abort-current-inline-script](#abort-current-inline-script) -* [abort-on-property-read](#abort-on-property-read) -* [abort-on-property-write](#abort-on-property-write) -* [abort-on-stack-trace](#abort-on-stack-trace) -* [adjust-setInterval](#adjust-setinterval) -* [adjust-setTimeout](#adjust-settimeout) -* [close-window](#close-window) -* [debug-current-inline-script](#debug-current-inline-script) -* [debug-on-property-read](#debug-on-property-read) -* [debug-on-property-write](#debug-on-property-write) -* [dir-string](#dir-string) -* [disable-newtab-links](#disable-newtab-links) -* [hide-in-shadow-dom](#hide-in-shadow-dom) -* [inject-css-in-shadow-dom](#inject-css-in-shadow-dom) -* [json-prune](#json-prune) -* [log-addEventListener](#log-addeventlistener) -* [log-eval](#log-eval) -* [log-on-stack-trace](#log-on-stack-trace) -* [log](#log) -* [m3u-prune](#m3u-prune) -* [no-topics](#no-topics) -* [noeval](#noeval) -* [nowebrtc](#nowebrtc) -* [prevent-addEventListener](#prevent-addeventlistener) -* [prevent-adfly](#prevent-adfly) -* [prevent-bab](#prevent-bab) -* [prevent-element-src-loading](#prevent-element-src-loading) -* [prevent-eval-if](#prevent-eval-if) -* [prevent-fab-3.2.0](#prevent-fab-3.2.0) -* [prevent-fetch](#prevent-fetch) -* [prevent-popads-net](#prevent-popads-net) -* [prevent-refresh](#prevent-refresh) -* [prevent-requestAnimationFrame](#prevent-requestanimationframe) -* [prevent-setInterval](#prevent-setinterval) -* [prevent-setTimeout](#prevent-settimeout) -* [prevent-window-open](#prevent-window-open) -* [prevent-xhr](#prevent-xhr) -* [remove-attr](#remove-attr) -* [remove-class](#remove-class) -* [remove-cookie](#remove-cookie) -* [remove-in-shadow-dom](#remove-in-shadow-dom) -* [set-attr](#set-attr) -* [set-constant](#set-constant) -* [set-cookie-reload](#set-cookie-reload) -* [set-cookie](#set-cookie) -* [set-local-storage-item](#set-local-storage-item) -* [set-popads-dummy](#set-popads-dummy) -* [set-session-storage-item](#set-session-storage-item) -* [xml-prune](#xml-prune) +# Available Scriptlets + +- [abort-current-inline-script](#abort-current-inline-script) +- [abort-on-property-read](#abort-on-property-read) +- [abort-on-property-write](#abort-on-property-write) +- [abort-on-stack-trace](#abort-on-stack-trace) +- [adjust-setInterval](#adjust-setinterval) +- [adjust-setTimeout](#adjust-settimeout) +- [close-window](#close-window) +- [debug-current-inline-script](#debug-current-inline-script) +- [debug-on-property-read](#debug-on-property-read) +- [debug-on-property-write](#debug-on-property-write) +- [dir-string](#dir-string) +- [disable-newtab-links](#disable-newtab-links) +- [hide-in-shadow-dom](#hide-in-shadow-dom) +- [inject-css-in-shadow-dom](#inject-css-in-shadow-dom) +- [json-prune](#json-prune) +- [log-addEventListener](#log-addeventlistener) +- [log-eval](#log-eval) +- [log-on-stack-trace](#log-on-stack-trace) +- [log](#log) +- [m3u-prune](#m3u-prune) +- [no-topics](#no-topics) +- [noeval](#noeval) +- [nowebrtc](#nowebrtc) +- [prevent-addEventListener](#prevent-addeventlistener) +- [prevent-adfly](#prevent-adfly) +- [prevent-bab](#prevent-bab) +- [prevent-element-src-loading](#prevent-element-src-loading) +- [prevent-eval-if](#prevent-eval-if) +- [prevent-fab-3.2.0](#prevent-fab-3.2.0) +- [prevent-fetch](#prevent-fetch) +- [prevent-popads-net](#prevent-popads-net) +- [prevent-refresh](#prevent-refresh) +- [prevent-requestAnimationFrame](#prevent-requestanimationframe) +- [prevent-setInterval](#prevent-setinterval) +- [prevent-setTimeout](#prevent-settimeout) +- [prevent-window-open](#prevent-window-open) +- [prevent-xhr](#prevent-xhr) +- [remove-attr](#remove-attr) +- [remove-class](#remove-class) +- [remove-cookie](#remove-cookie) +- [remove-in-shadow-dom](#remove-in-shadow-dom) +- [remove-node-text](#remove-node-text) +- [set-attr](#set-attr) +- [set-constant](#set-constant) +- [set-cookie-reload](#set-cookie-reload) +- [set-cookie](#set-cookie) +- [set-local-storage-item](#set-local-storage-item) +- [set-popads-dummy](#set-popads-dummy) +- [set-session-storage-item](#set-session-storage-item) +- [xml-prune](#xml-prune) +- [trusted-replace-node-text](#trusted-replace-node-text) + * * * -### ⚡️ abort-current-inline-script + +## ⚡️ abort-current-inline-script + +> Added in v1.0.4. Aborts an inline script when it attempts to **read** or **write to** the specified property AND when the contents of the ` ``` -3. Aborts inline scripts which are trying to access `window.alert` and match this regexp: `/Hello.+world/`. - ``` +1. Aborts inline scripts which are trying to access `window.alert` and match regexp `/Hello.+world/` + + ```adblock example.org#%#//scriptlet('abort-current-inline-script', 'alert', '/Hello.+world/') ``` For instance, the following scripts will be aborted: + ```html ``` + ```html ``` - This script will not be aborted: + And this script will not be aborted: + ```html ``` [Scriptlet source](../src/scriptlets/abort-current-inline-script.js) + * * * -### ⚡️ abort-on-property-read +## ⚡️ abort-on-property-read + +> Added in v1.0.4. Aborts a script when it attempts to **read** the specified property. @@ -120,17 +138,19 @@ Related UBO scriptlet: https://github.com/gorhill/uBlock/wiki/Resources-Library#abort-on-property-readjs- Related ABP source: -https://github.com/adblockplus/adblockpluscore/blob/6b2a309054cc23432102b85d13f12559639ef495/lib/content/snippets.js#L864 +https://gitlab.com/eyeo/snippets/-/blob/main/source/behavioral/abort-on-property-read.js -**Syntax** -``` +### Syntax + +```text example.org#%#//scriptlet('abort-on-property-read', property) ``` - `property` — required, path to a property (joined with `.` if needed). The property must be attached to `window` -**Examples** -``` +### Examples + +```adblock ! Aborts script when it tries to access `window.alert` example.org#%#//scriptlet('abort-on-property-read', 'alert') @@ -139,9 +159,12 @@ example.org#%#//scriptlet('abort-on-property-read', 'navigator.language') ``` [Scriptlet source](../src/scriptlets/abort-on-property-read.js) + * * * -### ⚡️ abort-on-property-write +## ⚡️ abort-on-property-write + +> Added in v1.0.4. Aborts a script when it attempts to **write** the specified property. @@ -149,33 +172,41 @@ Related UBO scriptlet: https://github.com/gorhill/uBlock/wiki/Resources-Library#abort-on-property-writejs- Related ABP source: -https://github.com/adblockplus/adblockpluscore/blob/6b2a309054cc23432102b85d13f12559639ef495/lib/content/snippets.js#L896 +https://gitlab.com/eyeo/snippets/-/blob/main/source/behavioral/abort-on-property-write.js -**Syntax** -``` +### Syntax + +```text example.org#%#//scriptlet('abort-on-property-write', property) ``` -- `property` — required, path to a property (joined with `.` if needed). The property must be attached to `window` +- `property` — required, path to a property (joined with `.` if needed). + The property must be attached to `window` -**Examples** -``` +### Examples + +```adblock ! Aborts script when it tries to set `window.adblock` value example.org#%#//scriptlet('abort-on-property-write', 'adblock') ``` [Scriptlet source](../src/scriptlets/abort-on-property-write.js) + * * * -### ⚡️ abort-on-stack-trace +## ⚡️ abort-on-stack-trace -Aborts a script when it attempts to utilize (read or write to) the specified property and it's error stack trace contains given value. +> Added in v1.5.0. + +Aborts a script when it attempts to utilize (read or write to) the specified property +and it's error stack trace contains given value. Related UBO scriptlet: https://github.com/gorhill/uBlock-for-firefox-legacy/commit/7099186ae54e70b588d5e99554a05d783cabc8ff -**Syntax** -``` +### Syntax + +```text example.com#%#//scriptlet('abort-on-stack-trace', property, stack) ``` @@ -185,152 +216,203 @@ example.com#%#//scriptlet('abort-on-stack-trace', property, stack) - `inlineScript` - `injectedScript` -**Examples** -``` -! Aborts script when it tries to access `window.Ya` and it's error stack trace contains `test.js` -example.org#%#//scriptlet('abort-on-stack-trace', 'Ya', 'test.js') +### Examples -! Aborts script when it tries to access `window.Ya.videoAd` and it's error stack trace contains `test.js` -example.org#%#//scriptlet('abort-on-stack-trace', 'Ya.videoAd', 'test.js') +1. Aborts script when it tries to access `window.Ya` and it's error stack trace contains `test.js` -! Aborts script when stack trace matches with any of these parameters -example.org#%#//scriptlet('abort-on-stack-trace', 'Ya', 'yandexFuncName') -example.org#%#//scriptlet('abort-on-stack-trace', 'Ya', 'yandexScriptName') + ```adblock + example.org#%#//scriptlet('abort-on-stack-trace', 'Ya', 'test.js') + ``` -! Aborts script when it tries to access `window.Ya` and it's an inline script -example.org#%#//scriptlet('abort-on-stack-trace', 'Ya', 'inlineScript') +1. Aborts script when it tries to access `window.Ya.videoAd` and it's error stack trace contains `test.js` -! Aborts script when it tries to access `window.Ya` and it's an injected script -example.org#%#//scriptlet('abort-on-stack-trace', 'Ya', 'injectedScript') -``` + ```adblock + example.org#%#//scriptlet('abort-on-stack-trace', 'Ya.videoAd', 'test.js') + ``` + +1. Aborts script when stack trace matches with any of these parameters + + ```adblock + example.org#%#//scriptlet('abort-on-stack-trace', 'Ya', 'yandexFuncName') + example.org#%#//scriptlet('abort-on-stack-trace', 'Ya', 'yandexScriptName') + ``` + +1. Aborts script when it tries to access `window.Ya` and it's an inline script + + ```adblock + example.org#%#//scriptlet('abort-on-stack-trace', 'Ya', 'inlineScript') + ``` + +1. Aborts script when it tries to access `window.Ya` and it's an injected script + + ```adblock + example.org#%#//scriptlet('abort-on-stack-trace', 'Ya', 'injectedScript') + ``` [Scriptlet source](../src/scriptlets/abort-on-stack-trace.js) + * * * -### ⚡️ adjust-setInterval +## ⚡️ adjust-setInterval + +> Added in v1.0.4. Adjusts delay for specified setInterval() callbacks. Related UBO scriptlet: https://github.com/gorhill/uBlock/wiki/Resources-Library#nano-setinterval-boosterjs- -**Syntax** -``` +### Syntax + +```text example.org#%#//scriptlet('adjust-setInterval'[, matchCallback [, matchDelay[, boost]]]) ``` - `matchCallback` — optional, string or regular expression for stringified callback matching; -defaults to match all callbacks; invalid regular expression will cause exit and rule will not work + defaults to match all callbacks; invalid regular expression will cause exit and rule will not work - `matchDelay` — optional, defaults to 1000, matching setInterval delay; decimal integer OR '*' for any delay -- `boost` — optional, default to 0.05, float, capped at 1000 times for up and 50 for down (0.001...50), setInterval delay multiplier +- `boost` — optional, default to 0.05, float, + capped at 1000 times for up and 50 for down (0.001...50), setInterval delay multiplier -**Examples** -1. Adjust all setInterval() x20 times where delay equal 1000ms: - ``` +### Examples + +1. Adjust all setInterval() x20 times where delay equal 1000ms + + ```adblock example.org#%#//scriptlet('adjust-setInterval') ``` -2. Adjust all setInterval() x20 times where callback matched with `example` and delay equal 1000ms - ``` +1. Adjust all setInterval() x20 times where callback matched with `example` and delay equal 1000ms + + ```adblock example.org#%#//scriptlet('adjust-setInterval', 'example') ``` -3. Adjust all setInterval() x20 times where callback matched with `example` and delay equal 400ms - ``` +1. Adjust all setInterval() x20 times where callback matched with `example` and delay equal 400ms + + ```adblock example.org#%#//scriptlet('adjust-setInterval', 'example', '400') ``` -4. Slow down setInterval() x2 times where callback matched with `example` and delay equal 1000ms - ``` +1. Slow down setInterval() x2 times where callback matched with `example` and delay equal 1000ms + + ```adblock example.org#%#//scriptlet('adjust-setInterval', 'example', '', '2') ``` -5. Adjust all setInterval() x50 times where delay equal 2000ms - ``` + +1. Adjust all setInterval() x50 times where delay equal 2000ms + + ```adblock example.org#%#//scriptlet('adjust-setInterval', '', '2000', '0.02') ``` -6. Adjust all setInterval() x1000 times where delay equal 2000ms - ``` + +1. Adjust all setInterval() x1000 times where delay equal 2000ms + + ```adblock example.org#%#//scriptlet('adjust-setInterval', '', '2000', '0.001') ``` -7. Adjust all setInterval() x50 times where delay is randomized - ``` + +1. Adjust all setInterval() x50 times where delay is randomized + + ```adblock example.org#%#//scriptlet('adjust-setInterval', '', '*', '0.02') ``` [Scriptlet source](../src/scriptlets/adjust-setInterval.js) + * * * -### ⚡️ adjust-setTimeout +## ⚡️ adjust-setTimeout + +> Added in v1.0.4. Adjusts delay for specified setTimeout() callbacks. Related UBO scriptlet: https://github.com/gorhill/uBlock/wiki/Resources-Library#nano-settimeout-boosterjs- -**Syntax** -``` +### Syntax + +```text example.org#%#//scriptlet('adjust-setTimeout'[, matchCallback [, matchDelay[, boost]]]) ``` - `matchCallback` — optional, string or regular expression for stringified callback matching; -defaults to match all callbacks; invalid regular expression will cause exit and rule will not work + defaults to match all callbacks; invalid regular expression will cause exit and rule will not work - `matchDelay` — optional, defaults to 1000, matching setTimeout delay; decimal integer OR '*' for any delay -- `boost` — optional, default to 0.05, float, capped at 1000 times for up and 50 for down (0.001...50), setTimeout delay multiplier +- `boost` — optional, default to 0.05, float, + capped at 1000 times for up and 50 for down (0.001...50), setTimeout delay multiplier -**Examples** -1. Adjust all setTimeout() x20 times where timeout equal 1000ms: - ``` +### Examples + +1. Adjust all setTimeout() x20 times where timeout equal 1000ms + + ```adblock example.org#%#//scriptlet('adjust-setTimeout') ``` -2. Adjust all setTimeout() x20 times where callback matched with `example` and timeout equal 1000ms - ``` +1. Adjust all setTimeout() x20 times where callback matched with `example` and timeout equal 1000ms + + ```adblock example.org#%#//scriptlet('adjust-setTimeout', 'example') ``` -3. Adjust all setTimeout() x20 times where callback matched with `example` and timeout equal 400ms - ``` +1. Adjust all setTimeout() x20 times where callback matched with `example` and timeout equal 400ms + + ```adblock example.org#%#//scriptlet('adjust-setTimeout', 'example', '400') ``` -4. Slow down setTimeout() x2 times where callback matched with `example` and timeout equal 1000ms - ``` +1. Slow down setTimeout() x2 times where callback matched with `example` and timeout equal 1000ms + + ```adblock example.org#%#//scriptlet('adjust-setTimeout', 'example', '', '2') ``` -5. Adjust all setTimeout() x50 times where timeout equal 2000ms - ``` + +1. Adjust all setTimeout() x50 times where timeout equal 2000ms + + ```adblock example.org#%#//scriptlet('adjust-setTimeout', '', '2000', '0.02') ``` -6. Adjust all setTimeout() x1000 times where timeout equal 2000ms - ``` + +1. Adjust all setTimeout() x1000 times where timeout equal 2000ms + + ```adblock example.org#%#//scriptlet('adjust-setTimeout', '', '2000', '0.001') ``` -7. Adjust all setTimeout() x20 times where callback matched with `test` and timeout is randomized - ``` + +1. Adjust all setTimeout() x20 times where callback matched with `test` and timeout is randomized + + ```adblock example.org#%#//scriptlet('adjust-setTimeout', 'test', '*') ``` [Scriptlet source](../src/scriptlets/adjust-setTimeout.js) + * * * -### ⚡️ close-window +## ⚡️ close-window + +> Added in v1.5.0. Closes the browser tab immediately. -> `window.close()` usage is restricted in Chrome. In this case -tab will only be closed when using AdGuard browser extension. +> `window.close()` usage is restricted in the Chrome browser. +> In this case tab will only be closed when using AdGuard Browser extension. -**Syntax** -``` +### Syntax + +```text example.org#%#//scriptlet('close-window'[, path]) ``` - `path` — optional, string or regular expression -matching the current location's path: `window.location.pathname` + `window.location.search`. -Defaults to execute on every page. + matching the current location's path: `window.location.pathname` + `window.location.search`. + Defaults to execute on every page. -**Examples** -``` +### Examples + +```adblock ! closes any example.org tab example.org#%#//scriptlet('close-window') @@ -339,56 +421,75 @@ example.org#%#//scriptlet('close-window', '/example-page.html') ``` [Scriptlet source](../src/scriptlets/close-window.js) + * * * -### ⚡️ debug-current-inline-script +## ⚡️ debug-current-inline-script -This scriptlet is basically the same as [abort-current-inline-script](#abort-current-inline-script), but instead of aborting it starts the debugger. +> Added in v1.0.4. -**It is not supposed to be used in production filter lists!** +This scriptlet is basically the same as [abort-current-inline-script](#abort-current-inline-script), +but instead of aborting it starts the debugger. -**Syntax** -``` +> It is not allowed for prod versions of filter lists. + +### Examples + +```adblock ! Aborts script when it tries to access `window.alert` example.org#%#//scriptlet('debug-current-inline-script', 'alert') ``` [Scriptlet source](../src/scriptlets/debug-current-inline-script.js) + * * * -### ⚡️ debug-on-property-read +## ⚡️ debug-on-property-read -This scriptlet is basically the same as [abort-on-property-read](#abort-on-property-read), but instead of aborting it starts the debugger. +> Added in v1.0.4. -**It is not supposed to be used in production filter lists!** +This scriptlet is basically the same as [abort-on-property-read](#abort-on-property-read), +but instead of aborting it starts the debugger. -**Syntax** -``` +> It is not allowed for prod versions of filter lists. + +### Examples + +```adblock ! Debug script if it tries to access `window.alert` example.org#%#//scriptlet('debug-on-property-read', 'alert') -! of `window.open` + +! or `window.open` example.org#%#//scriptlet('debug-on-property-read', 'open') ``` [Scriptlet source](../src/scriptlets/debug-on-property-read.js) + * * * -### ⚡️ debug-on-property-write +## ⚡️ debug-on-property-write -This scriptlet is basically the same as [abort-on-property-write](#abort-on-property-write), but instead of aborting it starts the debugger. +> Added in v1.0.4. -**It is not supposed to be used in production filter lists!** +This scriptlet is basically the same as [abort-on-property-write](#abort-on-property-write), +but instead of aborting it starts the debugger. -**Syntax** -``` +> It is not allowed for prod versions of filter lists. + +### Examples + +```adblock ! Aborts script when it tries to write in property `window.test` example.org#%#//scriptlet('debug-on-property-write', 'test') ``` [Scriptlet source](../src/scriptlets/debug-on-property-write.js) + * * * -### ⚡️ dir-string +## ⚡️ dir-string + +> Added in v1.0.4. Wraps the `console.dir` API to call the `toString` method of the argument. There are several adblock circumvention systems that detect browser devtools @@ -396,120 +497,144 @@ and hide themselves. Therefore, if we force them to think that devtools are open (using this scriptlet), it will automatically disable the adblock circumvention script. -Related ABP source: -https://github.com/adblockplus/adblockpluscore/blob/6b2a309054cc23432102b85d13f12559639ef495/lib/content/snippets.js#L766 +### Syntax -**Syntax** -``` +```text example.org#%#//scriptlet('dir-string'[, times]) ``` + - `times` — optional, the number of times to call the `toString` method of the argument to `console.dir` -**Example** -``` +### Examples + +```adblock ! Run 2 times example.org#%#//scriptlet('dir-string', '2') ``` [Scriptlet source](../src/scriptlets/dir-string.js) + * * * -### ⚡️ disable-newtab-links +## ⚡️ disable-newtab-links + +> Added in v1.0.4. Prevents opening new tabs and windows if there is `target` attribute in element. Related UBO scriptlet: https://github.com/gorhill/uBlock/wiki/Resources-Library#disable-newtab-linksjs- -**Syntax** -``` +### Syntax + +```adblock example.org#%#//scriptlet('disable-newtab-links') ``` [Scriptlet source](../src/scriptlets/disable-newtab-links.js) + * * * -### ⚡️ hide-in-shadow-dom +## ⚡️ hide-in-shadow-dom + +> Added in v1.3.0. Hides elements inside open shadow DOM elements. -**Syntax** -``` +### Syntax + +```text example.org#%#//scriptlet('hide-in-shadow-dom', selector[, baseSelector]) ``` - `selector` — required, CSS selector of element in shadow-dom to hide - `baseSelector` — optional, selector of specific page DOM element, -narrows down the part of the page DOM where shadow-dom host supposed to be, -defaults to document.documentElement + narrows down the part of the page DOM where shadow-dom host supposed to be, + defaults to document.documentElement -> `baseSelector` should match element of the page DOM, but not of shadow DOM +> `baseSelector` should match element of the page DOM, but not of shadow DOM. -**Examples** -``` +### Examples + +```adblock ! hides menu bar -virustotal.com#%#//scriptlet('hide-in-shadow-dom', 'iron-pages', 'vt-virustotal-app') +example.com#%#//scriptlet('hide-in-shadow-dom', '.storyAd', '#app') ! hides floating element -virustotal.com#%#//scriptlet('hide-in-shadow-dom', 'vt-ui-contact-fab') +example.com#%#//scriptlet('hide-in-shadow-dom', '.contact-fab') ``` [Scriptlet source](../src/scriptlets/hide-in-shadow-dom.js) + * * * -### ⚡️ inject-css-in-shadow-dom +## ⚡️ inject-css-in-shadow-dom + +> Added in v1.8.2. Injects CSS rule into selected Shadow DOM subtrees on a page -**Syntax** -``` +### Syntax + +```text example.org#%#//scriptlet('inject-css-in-shadow-dom', cssRule[, hostSelector]) ``` - `cssRule` — required, string representing a single css rule -- `hostSelector` — optional, string, selector to match shadow host elements. CSS rule will be only applied to shadow roots inside these elements. -Defaults to injecting css rule into all available roots. +- `hostSelector` — optional, string, selector to match shadow host elements. + CSS rule will be only applied to shadow roots inside these elements. + Defaults to injecting css rule into all available roots. + +### Examples -**Examples** 1. Apply style to all shadow dom subtrees -``` -example.org#%#//scriptlet('inject-css-in-shadow-dom', '#advertisement { display: none !important; }') -``` -2. Apply style to a specific shadow dom subtree -``` -example.org#%#//scriptlet('inject-css-in-shadow-dom', '#content { margin-top: 0 !important; }', '.row > #hidden') -``` + ```adblock + example.org#%#//scriptlet('inject-css-in-shadow-dom', '#advertisement { display: none !important; }') + ``` + +1. Apply style to a specific shadow dom subtree + + ```adblock + example.org#%#//scriptlet('inject-css-in-shadow-dom', '#content { margin-top: 0 !important; }', '#banner') + ``` [Scriptlet source](../src/scriptlets/inject-css-in-shadow-dom.js) + * * * -### ⚡️ json-prune +## ⚡️ json-prune + +> Added in v1.1.0. -Removes specified properties from the result of calling JSON.parse and returns the caller +Removes specified properties from the result of calling JSON.parse and returns the caller. Related UBO scriptlet: https://github.com/gorhill/uBlock/wiki/Resources-Library#json-prunejs- Related ABP source: -https://github.com/adblockplus/adblockpluscore/blob/master/lib/content/snippets.js#L1285 +https://gitlab.com/eyeo/snippets/-/blob/main/source/behavioral/json-prune.js -**Syntax** -``` +### Syntax + +```text example.org#%#//scriptlet('json-prune'[, propsToRemove [, obligatoryProps [, stack]]]) ``` - `propsToRemove` — optional, string of space-separated properties to remove -- `obligatoryProps` — optional, string of space-separated properties which must be all present for the pruning to occur +- `obligatoryProps` — optional, string of space-separated properties + which must be all present for the pruning to occur - `stack` — optional, string or regular expression that must match the current function call stack trace; -if regular expression is invalid it will be skipped + if regular expression is invalid it will be skipped -> Note please that you can use wildcard `*` for chain property name. -e.g. 'ad.*.src' instead of 'ad.0.src ad.1.src ad.2.src ...' +> Note please that you can use wildcard `*` for chain property name, +> e.g. `ad.*.src` instead of `ad.0.src ad.1.src ad.2.src`. + +### Examples -**Examples** 1. Removes property `example` from the results of JSON.parse call - ``` + + ```adblock example.org#%#//scriptlet('json-prune', 'example') ``` @@ -519,8 +644,9 @@ e.g. 'ad.*.src' instead of 'ad.0.src ad.1.src ad.2.src ...' JSON.parse('{"one":1,"example":true}') ``` -2. If there are no specified properties in the result of JSON.parse call, pruning will NOT occur - ``` +1. If there are no specified properties in the result of JSON.parse call, pruning will NOT occur + + ```adblock example.org#%#//scriptlet('json-prune', 'one', 'obligatoryProp') ``` @@ -530,146 +656,187 @@ e.g. 'ad.*.src' instead of 'ad.0.src ad.1.src ad.2.src ...' JSON.parse('{"one":1,"two":2}') ``` -3. A property in a list of properties can be a chain of properties +1. A property in a list of properties can be a chain of properties - ``` - example.org#%#//scriptlet('json-prune', 'a.b', 'adpath.url.first') + ```adblock + example.org#%#//scriptlet('json-prune', 'a.b', 'ads.url.first') ``` -4. Removes property `content.ad` from the results of JSON.parse call if its error stack trace contains `test.js` - ``` +1. Removes property `content.ad` from the results of JSON.parse call if its error stack trace contains `test.js` + + ```adblock example.org#%#//scriptlet('json-prune', 'content.ad', '', 'test.js') ``` -5. A property in a list of properties can be a chain of properties with wildcard in it +1. A property in a list of properties can be a chain of properties with wildcard in it - ``` - example.org#%#//scriptlet('json-prune', 'content.*.media.src', 'content.*.media.preroll') + ```adblock + example.org#%#//scriptlet('json-prune', 'content.*.media.src', 'content.*.media.ad') ``` -6. Call with no arguments will log the current hostname and json payload at the console - ``` +1. Call with no arguments will log the current hostname and json payload at the console + + ```adblock example.org#%#//scriptlet('json-prune') ``` -7. Call with only second argument will log the current hostname and matched json payload at the console - ``` +1. Call with only second argument will log the current hostname and matched json payload at the console + + ```adblock example.org#%#//scriptlet('json-prune', '', '"id":"117458"') ``` [Scriptlet source](../src/scriptlets/json-prune.js) + * * * -### ⚡️ log-addEventListener +## ⚡️ log-addEventListener + +> Added in v1.0.4. Logs all addEventListener calls to the console. Related UBO scriptlet: https://github.com/gorhill/uBlock/wiki/Resources-Library#addeventlistener-loggerjs- -**Syntax** -``` +### Syntax + +```adblock example.org#%#//scriptlet('log-addEventListener') ``` [Scriptlet source](../src/scriptlets/log-addEventListener.js) + * * * -### ⚡️ log-eval +## ⚡️ log-eval + +> Added in v1.0.4. Logs all `eval()` or `new Function()` calls to the console. -**Syntax** -``` +### Syntax + +```adblock example.org#%#//scriptlet('log-eval') ``` [Scriptlet source](../src/scriptlets/log-eval.js) + * * * -### ⚡️ log-on-stack-trace +## ⚡️ log-on-stack-trace + +> Added in v1.5.0. + +This scriptlet is basically the same as [abort-on-stack-trace](#abort-on-stack-trace), +but instead of aborting it logs: -This scriptlet is basically the same as [abort-on-stack-trace](#abort-on-stack-trace), but instead of aborting it logs: - function and source script names pairs that access the given property - was that get or set attempt - script being injected or inline -**Syntax** -``` +### Syntax + +```text example.com#%#//scriptlet('log-on-stack-trace', 'property') ``` - `property` — required, path to a property. The property must be attached to window. [Scriptlet source](../src/scriptlets/log-on-stack-trace.js) + * * * -### ⚡️ log +## ⚡️ log + +> Added in v1.0.4. A simple scriptlet which only purpose is to print arguments to console. This scriptlet can be helpful for debugging and troubleshooting other scriptlets. -**Example** -``` +### Examples + +```adblock example.org#%#//scriptlet('log', 'arg1', 'arg2') ``` [Scriptlet source](../src/scriptlets/log.js) + * * * -### ⚡️ m3u-prune +## ⚡️ m3u-prune + +> Added in v1.9.1. Removes content from the specified M3U file. +Related UBO scriptlet: +https://github.com/gorhill/uBlock/wiki/Resources-Library#m3u-prunejs- -**Syntax** -``` +### Syntax + +```text example.org#%#//scriptlet('m3u-prune'[, propsToRemove[, urlToMatch]]) ``` -- `propsToRemove` — optional, string or regular expression to match the URL line (segment) which will be removed alongside with its tags +- `propsToRemove` — optional, string or regular expression + to match the URL line (segment) which will be removed alongside with its tags - `urlToMatch` — optional, string or regular expression for matching the request's URL + > Usage with no arguments will log response payload and URL to browser console; -which is useful for debugging but prohibited for production filter lists. +> it may be useful for debugging but it is not allowed for prod versions of filter lists. -**Examples** -1. Removes a tag which contains `tvessaiprod.nbcuni.com/video/`, from all requests - ``` - example.org#%#//scriptlet('m3u-prune', 'tvessaiprod.nbcuni.com/video/') - ``` +### Examples -2. Removes a line which contains `tvessaiprod.nbcuni.com/video/`, only if request's URL contains `.m3u8` - ``` - example.org#%#//scriptlet('m3u-prune', 'tvessaiprod.nbcuni.com/video/', '.m3u8') +1. Removes a tag which contains `example.com/video/`, from all requests + + ```adblock + example.org#%#//scriptlet('m3u-prune', 'example.com/video/') ``` -3. Call with no arguments will log response payload and URL at the console +1. Removes a line which contains `example.com/video/`, only if request's URL contains `.m3u8` + + ```adblock + example.org#%#//scriptlet('m3u-prune', 'example.com/video/', '.m3u8') ``` + +1. Call with no arguments will log response payload and URL at the console + + ```adblock example.org#%#//scriptlet('m3u-prune') ``` -4. Call with only `urlToMatch` argument will log response payload and URL only for the matched URL - ``` +1. Call with only `urlToMatch` argument will log response payload and URL only for the matched URL + + ```adblock example.org#%#//scriptlet('m3u-prune', '', '.m3u8') ``` [Scriptlet source](../src/scriptlets/m3u-prune.js) + * * * -### ⚡️ no-topics +## ⚡️ no-topics + +> Added in v1.6.18. -Prevents using The Topics API +Prevents using the Topics API. https://developer.chrome.com/docs/privacy-sandbox/topics/ -**Syntax** -``` +### Syntax + +```adblock example.org#%#//scriptlet('no-topics') ``` [Scriptlet source](../src/scriptlets/no-topics.js) + * * * -### ⚡️ noeval +## ⚡️ noeval + +> Added in v1.0.4. Prevents page to use eval. Notifies about attempts in the console @@ -680,54 +847,67 @@ https://github.com/gorhill/uBlock/wiki/Resources-Library#noevaljs- It also can be used as `$redirect` rules sometimes. See [redirect description](../wiki/about-redirects.md#noeval). -**Syntax** -``` +### Syntax + +```adblock example.org#%#//scriptlet('noeval') ``` [Scriptlet source](../src/scriptlets/noeval.js) + * * * -### ⚡️ nowebrtc +## ⚡️ nowebrtc -Disables WebRTC by overriding `RTCPeerConnection`. The overridden function will log every attempt to create a new connection. +> Added in v1.0.4. + +Disables WebRTC by overriding `RTCPeerConnection`. +The overridden function will log every attempt to create a new connection. Related UBO scriptlet: https://github.com/gorhill/uBlock/wiki/Resources-Library#nowebrtcjs- -**Syntax** -``` +### Syntax + +```adblock example.org#%#//scriptlet('nowebrtc') ``` [Scriptlet source](../src/scriptlets/nowebrtc.js) + * * * -### ⚡️ prevent-addEventListener +## ⚡️ prevent-addEventListener + +> Added in v1.0.4. Prevents adding event listeners for the specified events and callbacks. Related UBO scriptlet: https://github.com/gorhill/uBlock/wiki/Resources-Library#addeventlistener-defuserjs- -**Syntax** -``` +### Syntax + +```text example.org#%#//scriptlet('prevent-addEventListener'[, typeSearch[, listenerSearch]]) ``` - `typeSearch` — optional, string or regular expression matching the type (event name); -defaults to match all types; invalid regular expression will cause exit and rule will not work + defaults to match all types; invalid regular expression will cause exit and rule will not work - `listenerSearch` — optional, string or regular expression matching the listener function body; -defaults to match all listeners; invalid regular expression will cause exit and rule will not work + defaults to match all listeners; invalid regular expression will cause exit and rule will not work -**Examples** -1. Prevent all `click` listeners: - ``` +### Examples + +1. Prevent all `click` listeners + + ```adblock example.org#%#//scriptlet('prevent-addEventListener', 'click') ``` -2. Prevent 'click' listeners with the callback body containing `searchString`. - ``` +1. Prevent 'click' listeners with the callback body containing `searchString` + + ```adblock example.org#%#//scriptlet('prevent-addEventListener', 'click', 'searchString') ``` @@ -740,24 +920,31 @@ defaults to match all listeners; invalid regular expression will cause exit and ``` [Scriptlet source](../src/scriptlets/prevent-addEventListener.js) + * * * -### ⚡️ prevent-adfly +## ⚡️ prevent-adfly + +> Added in v1.0.4. Prevents anti-adblock scripts on adfly short links. Related UBO scriptlet: https://github.com/gorhill/uBlock/wiki/Resources-Library#adfly-defuserjs- -**Syntax** -``` +### Syntax + +```adblock example.org#%#//scriptlet('prevent-adfly') ``` [Scriptlet source](../src/scriptlets/prevent-adfly.js) + * * * -### ⚡️ prevent-bab +## ⚡️ prevent-bab + +> Added in v1.0.4. Prevents BlockAdblock script from detecting an ad blocker. @@ -767,135 +954,169 @@ https://github.com/gorhill/uBlock/wiki/Resources-Library#bab-defuserjs- It also can be used as `$redirect` sometimes. See [redirect description](../wiki/about-redirects.md#prevent-bab). -**Syntax** -``` +### Syntax + +```adblock example.org#%#//scriptlet('prevent-bab') ``` [Scriptlet source](../src/scriptlets/prevent-bab.js) + * * * -### ⚡️ prevent-element-src-loading +## ⚡️ prevent-element-src-loading + +> Added in v1.6.2. Prevents target element source loading without triggering 'onerror' listeners and not breaking 'onload' ones. -**Syntax** -``` +### Syntax + +```text example.org#%#//scriptlet('prevent-element-src-loading', tagName, match) ``` -- `tagName` — required, case-insensitive target element tagName which `src` property resource loading will be silently prevented; possible values: +- `tagName` — required, case-insensitive target element tagName + which `src` property resource loading will be silently prevented; possible values: - `script` - `img` - `iframe` + - `link` - `match` — required, string or regular expression for matching the element's URL; -**Examples** -1. Prevent script source loading: -``` +### Examples + +1. Prevent script source loading + + ```adblock example.org#%#//scriptlet('prevent-element-src-loading', 'script' ,'adsbygoogle') -``` + ``` [Scriptlet source](../src/scriptlets/prevent-element-src-loading.js) + * * * -### ⚡️ prevent-eval-if +## ⚡️ prevent-eval-if + +> Added in v1.0.4. Prevents page to use eval matching payload. Related UBO scriptlet: https://github.com/gorhill/uBlock/wiki/Resources-Library#noeval-ifjs- -**Syntax** -``` +### Syntax + +```text example.org#%#//scriptlet('prevent-eval-if'[, search]) ``` - `search` — optional, string or regular expression matching the stringified eval payload; -defaults to match all stringified eval payloads; -invalid regular expression will cause exit and rule will not work + defaults to match all stringified eval payloads; + invalid regular expression will cause exit and rule will not work -**Examples** -``` +### Examples + +```adblock ! Prevents eval if it matches 'test' example.org#%#//scriptlet('prevent-eval-if', 'test') ``` [Scriptlet source](../src/scriptlets/prevent-eval-if.js) + * * * -### ⚡️ prevent-fab-3.2.0 +## ⚡️ prevent-fab-3.2.0 + +> Added in v1.0.4. Prevents execution of the FAB script v3.2.0. Related UBO scriptlet: https://github.com/gorhill/uBlock/wiki/Resources-Library#fuckadblockjs-320- -**Syntax** -``` +### Syntax + +```adblock example.org#%#//scriptlet('prevent-fab-3.2.0') ``` [Scriptlet source](../src/scriptlets/prevent-fab-3.2.0.js) + * * * -### ⚡️ prevent-fetch +## ⚡️ prevent-fetch + +> Added in v1.3.18. -Prevents `fetch` calls if **all** given parameters match +Prevents `fetch` calls if **all** given parameters match. Related UBO scriptlet: https://github.com/gorhill/uBlock/wiki/Resources-Library#no-fetch-ifjs- -**Syntax** -``` +### Syntax + +```text example.org#%#//scriptlet('prevent-fetch'[, propsToMatch[, responseBody[, responseType]]]) ``` - `propsToMatch` — optional, string of space-separated properties to match; possible props: - - string or regular expression for matching the URL passed to fetch call; empty string, wildcard `*` or invalid regular expression will match all fetch calls - - colon-separated pairs `name:value` where - - `name` is [`init` option name](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch#parameters) - - `value` is string or regular expression for matching the value of the option passed to fetch call; invalid regular expression will cause any value matching -- `responseBody` — optional, string for defining response body value, defaults to `emptyObj`. Possible values: - - `emptyObj` — empty object - - `emptyArr` — empty array -- `responseType` — optional, string for defining response type, defaults to `default`. Possible values: - - `default` - - `opaque` + - string or regular expression for matching the URL passed to fetch call; + empty string, wildcard `*` or invalid regular expression will match all fetch calls + - colon-separated pairs `name:value` where + + - `name` is [`init` option name](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch#parameters) + - `value` is string or regular expression for matching the value of the option passed to fetch call; + invalid regular expression will cause any value matching +- `responseBody` — optional, string for defining response body value, + defaults to `emptyObj`. Possible values: + - `emptyObj` — empty object + - `emptyArr` — empty array +- `responseType` — optional, string for defining response type, + original response type is used if not specified. Possible values: + - `default` + - `opaque` > Usage with no arguments will log fetch calls to browser console; -which is useful for debugging but not permitted for production filter lists. +> it may be useful for debugging but it is not allowed for prod versions of filter lists. + +### Examples -**Examples** 1. Log all fetch calls - ``` + + ```adblock example.org#%#//scriptlet('prevent-fetch') ``` -2. Prevent all fetch calls - ``` +1. Prevent all fetch calls + + ```adblock example.org#%#//scriptlet('prevent-fetch', '*') - OR + ! or example.org#%#//scriptlet('prevent-fetch', '') ``` -3. Prevent fetch call for specific url - ``` +1. Prevent fetch call for specific url + + ```adblock example.org#%#//scriptlet('prevent-fetch', '/url\\.part/') ``` -4. Prevent fetch call for specific request method - ``` +1. Prevent fetch call for specific request method + + ```adblock example.org#%#//scriptlet('prevent-fetch', 'method:HEAD') ``` -5. Prevent fetch call for specific url and request method - ``` +1. Prevent fetch call for specific url and request method + + ```adblock example.org#%#//scriptlet('prevent-fetch', '/specified_url_part/ method:/HEAD|GET/') ``` -6. Prevent fetch call and specify response body value - ``` +1. Prevent fetch call and specify response body value + + ```adblock ! Specify response body for fetch call to a specific url example.org#%#//scriptlet('prevent-fetch', '/specified_url_part/ method:/HEAD|GET/', 'emptyArr') @@ -903,58 +1124,74 @@ which is useful for debugging but not permitted for production filter lists. example.org#%#//scriptlet('prevent-fetch', '', 'emptyArr') ``` -7. Prevent all fetch calls and specify response type value - ``` +1. Prevent all fetch calls and specify response type value + + ```adblock example.org#%#//scriptlet('prevent-fetch', '*', '', 'opaque') ``` [Scriptlet source](../src/scriptlets/prevent-fetch.js) + * * * -### ⚡️ prevent-popads-net +## ⚡️ prevent-popads-net + +> Added in v1.0.4. Aborts on property write (PopAds, popns), throws reference error with random id. Related UBO scriptlet: https://github.com/gorhill/uBlock/wiki/Resources-Library#popadsnetjs- -**Syntax** -``` +### Syntax + +```adblock example.org#%#//scriptlet('prevent-popads-net') ``` [Scriptlet source](../src/scriptlets/prevent-popads-net.js) + * * * -### ⚡️ prevent-refresh +## ⚡️ prevent-refresh + +> Added in v1.6.2. Prevents reloading of a document through a meta "refresh" tag. Related UBO scriptlet: https://github.com/gorhill/uBlock/wiki/Resources-Library#refresh-defuserjs- -**Syntax** -``` +### Syntax + +```text example.org#%#//scriptlet('prevent-refresh'[, delay]) ``` -- `delay` — optional, number of seconds for delay that indicates when scriptlet should run. If not set, source tag value will be applied. +- `delay` — optional, number of seconds for delay that indicates when scriptlet should run. + If not set, source tag value will be applied. -**Examples** -1. Prevent reloading of a document through a meta "refresh" tag. -``` - enrt.eu#%#//scriptlet('prevent-refresh') -``` +### Examples -2. Prevent reloading of a document with delay. -``` - cryptodirectories.com#%#//scriptlet('prevent-refresh', 3) -``` +1. Prevent reloading of a document through a meta "refresh" tag + + ```adblock + example.org#%#//scriptlet('prevent-refresh') + ``` + +1. Prevent reloading of a document with delay + + ```adblock + example.com#%#//scriptlet('prevent-refresh', 3) + ``` [Scriptlet source](../src/scriptlets/prevent-refresh.js) + * * * -### ⚡️ prevent-requestAnimationFrame +## ⚡️ prevent-requestAnimationFrame + +> Added in v1.1.15. Prevents a `requestAnimationFrame` call if the text of the callback is matching the specified search string which does not start with `!`; @@ -963,25 +1200,30 @@ otherwise mismatched calls should be defused. Related UBO scriptlet: https://github.com/gorhill/uBlock/wiki/Resources-Library#no-requestanimationframe-ifjs- -**Syntax** -``` +### Syntax + +```text example.org#%#//scriptlet('prevent-requestAnimationFrame'[, search]) ``` -- `search` — optional, string or regular expression; invalid regular expression will be skipped and all callbacks will be matched. -If starts with `!`, scriptlet will not match the stringified callback but all other will be defused. -If do not start with `!`, the stringified callback will be matched. +- `search` — optional, string or regular expression; + invalid regular expression will be skipped and all callbacks will be matched. + If starts with `!`, scriptlet will not match the stringified callback but all other will be defused. + If do not start with `!`, the stringified callback will be matched. + +> Call with no argument will log all requestAnimationFrame calls, +> it may be useful for debugging but it is not allowed for prod versions of filter lists. + +### Examples -Call with no argument will log all requestAnimationFrame calls while debugging. -So do not use the scriptlet without any parameter in production filter lists. +1. Prevents `requestAnimationFrame` calls if the callback matches `/\.test/` -**Examples** -1. Prevents `requestAnimationFrame` calls if the callback matches `/\.test/`. - ```bash + ```adblock example.org#%#//scriptlet('prevent-requestAnimationFrame', '/\.test/') ``` For instance, the following call will be prevented: + ```javascript var times = 0; requestAnimationFrame(function change() { @@ -992,8 +1234,10 @@ So do not use the scriptlet without any parameter in production filter lists. } }); ``` -2. Prevents `requestAnimationFrame` calls if **does not match** 'check'. - ```bash + +1. Prevents `requestAnimationFrame` calls if **does not match** 'check' + + ```adblock example.org#%#//scriptlet('prevent-requestAnimationFrame', '!check') ``` @@ -1020,57 +1264,69 @@ So do not use the scriptlet without any parameter in production filter lists. ``` [Scriptlet source](../src/scriptlets/prevent-requestAnimationFrame.js) + * * * -### ⚡️ prevent-setInterval +## ⚡️ prevent-setInterval + +> Added in v1.0.4. Prevents a `setInterval` call if: -1) the text of the callback is matching the specified `matchCallback` string/regexp which does not start with `!`; -otherwise mismatched calls should be defused; -2) the delay is matching the specified `matchDelay`; otherwise mismatched calls should be defused. + +1. The text of the callback is matching the specified `matchCallback` string/regexp which does not start with `!`; + otherwise mismatched calls should be defused. +1. The delay is matching the specified `matchDelay`; otherwise mismatched calls should be defused. Related UBO scriptlet: https://github.com/gorhill/uBlock/wiki/Resources-Library#no-setinterval-ifjs- -**Syntax** -``` +### Syntax + +```text example.org#%#//scriptlet('prevent-setInterval'[, matchCallback[, matchDelay]]) ``` -Call with no arguments will log calls to setInterval while debugging (`log-setInterval` superseding), -so production filter lists' rules definitely require at least one of the parameters: -- `matchCallback` — optional, string or regular expression; invalid regular expression will be skipped and all callbacks will be matched. -If starts with `!`, scriptlet will not match the stringified callback but all other will be defused. -If do not start with `!`, the stringified callback will be matched. -If not set, prevents all `setInterval` calls due to specified `matchDelay`. +> Call with no arguments will log all setInterval calls (`log-setInterval` superseding), +> it may be useful for debugging but it is not allowed for prod versions of filter lists. + +- `matchCallback` — optional, string or regular expression; + invalid regular expression will be skipped and all callbacks will be matched. + If starts with `!`, scriptlet will not match the stringified callback but all other will be defused. + If do not start with `!`, the stringified callback will be matched. + If not set, prevents all `setInterval` calls due to specified `matchDelay`. - `matchDelay` — optional, must be an integer. -If starts with `!`, scriptlet will not match the delay but all other will be defused. -If do not start with `!`, the delay passed to the `setInterval` call will be matched. -Decimal delay values will be rounded down, e.g `10.95` will be matched by `matchDelay` with value `10`. + If starts with `!`, scriptlet will not match the delay but all other will be defused. + If do not start with `!`, the delay passed to the `setInterval` call will be matched. + Decimal delay values will be rounded down, e.g `10.95` will be matched by `matchDelay` with value `10`. > If `prevent-setInterval` log looks like `setInterval(undefined, 1000)`, -it means that no callback was passed to setInterval() and that's not scriptlet issue -and obviously it can not be matched by `matchCallback`. +> it means that no callback was passed to setInterval() and that's not scriptlet issue +> and obviously it can not be matched by `matchCallback`. + +### Examples - **Examples** -1. Prevents `setInterval` calls if the callback matches `/\.test/` regardless of the delay. - ```bash +1. Prevents `setInterval` calls if the callback matches `/\.test/` regardless of the delay + + ```adblock example.org#%#//scriptlet('prevent-setInterval', '/\.test/') ``` For instance, the following call will be prevented: + ```javascript setInterval(function () { window.test = "value"; }, 100); ``` -2. Prevents `setInterval` calls if the callback does not contain `value`. - ``` +1. Prevents `setInterval` calls if the callback does not contain `value` + + ```adblock example.org#%#//scriptlet('prevent-setInterval', '!value') ``` For instance, only the first of the following calls will be prevented: + ```javascript setInterval(function () { window.test = "test -- prevented"; @@ -1083,12 +1339,14 @@ and obviously it can not be matched by `matchCallback`. }, 500); ``` -3. Prevents `setInterval` calls if the callback contains `value` and the delay is not set to `300`. - ``` +1. Prevents `setInterval` calls if the callback contains `value` and the delay is not set to `300` + + ```adblock example.org#%#//scriptlet('prevent-setInterval', 'value', '!300') ``` For instance, only the first of the following calls will not be prevented: + ```javascript setInterval(function () { window.test = "value 1 -- executed"; @@ -1101,12 +1359,14 @@ and obviously it can not be matched by `matchCallback`. }, 500); ``` -4. Prevents `setInterval` calls if the callback does not contain `value` and the delay is not set to `300`. - ``` +1. Prevents `setInterval` calls if the callback does not contain `value` and the delay is not set to `300` + + ```adblock example.org#%#//scriptlet('prevent-setInterval', '!value', '!300') ``` For instance, only the second of the following calls will be prevented: + ```javascript setInterval(function () { window.test = "test -- executed"; @@ -1122,12 +1382,14 @@ and obviously it can not be matched by `matchCallback`. }, 500); ``` -5. Prevents `setInterval` calls if the callback contains `value` and delay is a decimal. - ``` +1. Prevents `setInterval` calls if the callback contains `value` and delay is a decimal number + + ```adblock example.org#%#//scriptlet('prevent-setInterval', 'value', '300') ``` For instance, the following calls will be prevented: + ```javascript setInterval(function () { window.test = "value"; @@ -1138,57 +1400,69 @@ and obviously it can not be matched by `matchCallback`. ``` [Scriptlet source](../src/scriptlets/prevent-setInterval.js) + * * * -### ⚡️ prevent-setTimeout +## ⚡️ prevent-setTimeout + +> Added in v1.0.4. Prevents a `setTimeout` call if: -1) the text of the callback is matching the specified `matchCallback` string/regexp which does not start with `!`; -otherwise mismatched calls should be defused; -2) the delay is matching the specified `matchDelay`; otherwise mismatched calls should be defused. + +1. The text of the callback is matching the specified `matchCallback` string/regexp which does not start with `!`; + otherwise mismatched calls should be defused. +1. The delay is matching the specified `matchDelay`; otherwise mismatched calls should be defused. Related UBO scriptlet: https://github.com/gorhill/uBlock/wiki/Resources-Library#no-settimeout-ifjs- -**Syntax** -``` +### Syntax + +```text example.org#%#//scriptlet('prevent-setTimeout'[, matchCallback[, matchDelay]]) ``` -Call with no arguments will log calls to setTimeout while debugging (`log-setTimeout` superseding), -so production filter lists' rules definitely require at least one of the parameters: -- `matchCallback` — optional, string or regular expression; invalid regular expression will be skipped and all callbacks will be matched. -If starts with `!`, scriptlet will not match the stringified callback but all other will be defused. -If do not start with `!`, the stringified callback will be matched. -If not set, prevents all `setTimeout` calls due to specified `matchDelay`. +> Call with no arguments will log all setTimeout calls (`log-setTimeout` superseding), +> it may be useful for debugging but it is not allowed for prod versions of filter lists. + +- `matchCallback` — optional, string or regular expression; + invalid regular expression will be skipped and all callbacks will be matched. + If starts with `!`, scriptlet will not match the stringified callback but all other will be defused. + If do not start with `!`, the stringified callback will be matched. + If not set, prevents all `setTimeout` calls due to specified `matchDelay`. - `matchDelay` — optional, must be an integer. -If starts with `!`, scriptlet will not match the delay but all other will be defused. -If do not start with `!`, the delay passed to the `setTimeout` call will be matched. -Decimal delay values will be rounded down, e.g `10.95` will be matched by `matchDelay` with value `10`. + If starts with `!`, scriptlet will not match the delay but all other will be defused. + If do not start with `!`, the delay passed to the `setTimeout` call will be matched. + Decimal delay values will be rounded down, e.g `10.95` will be matched by `matchDelay` with value `10`. > If `prevent-setTimeout` log looks like `setTimeout(undefined, 1000)`, -it means that no callback was passed to setTimeout() and that's not scriptlet issue -and obviously it can not be matched by `matchCallback`. +> it means that no callback was passed to setTimeout() and that's not scriptlet issue +> and obviously it can not be matched by `matchCallback`. + +### Examples + +1. Prevents `setTimeout` calls if the callback matches `/\.test/` regardless of the delay -**Examples** -1. Prevents `setTimeout` calls if the callback matches `/\.test/` regardless of the delay. - ```bash + ```adblock example.org#%#//scriptlet('prevent-setTimeout', '/\.test/') ``` For instance, the following call will be prevented: + ```javascript setTimeout(function () { window.test = "value"; }, 100); ``` -2. Prevents `setTimeout` calls if the callback does not contain `value`. - ``` +1. Prevents `setTimeout` calls if the callback does not contain `value` + + ```adblock example.org#%#//scriptlet('prevent-setTimeout', '!value') ``` For instance, only the first of the following calls will be prevented: + ```javascript setTimeout(function () { window.test = "test -- prevented"; @@ -1201,12 +1475,14 @@ and obviously it can not be matched by `matchCallback`. }, 500); ``` -3. Prevents `setTimeout` calls if the callback contains `value` and the delay is not set to `300`. - ``` +1. Prevents `setTimeout` calls if the callback contains `value` and the delay is not set to `300` + + ```adblock example.org#%#//scriptlet('prevent-setTimeout', 'value', '!300') ``` For instance, only the first of the following calls will not be prevented: + ```javascript setTimeout(function () { window.test = "value 1 -- executed"; @@ -1219,12 +1495,14 @@ and obviously it can not be matched by `matchCallback`. }, 500); ``` -4. Prevents `setTimeout` calls if the callback does not contain `value` and the delay is not set to `300`. - ``` +1. Prevents `setTimeout` calls if the callback does not contain `value` and the delay is not set to `300` + + ```adblock example.org#%#//scriptlet('prevent-setTimeout', '!value', '!300') ``` For instance, only the second of the following calls will be prevented: + ```javascript setTimeout(function () { window.test = "test -- executed"; @@ -1240,12 +1518,14 @@ and obviously it can not be matched by `matchCallback`. }, 500); ``` -5. Prevents `setTimeout` calls if the callback contains `value` and delay is a decimal. - ``` +1. Prevents `setTimeout` calls if the callback contains `value` and delay is a decimal + + ```adblock example.org#%#//scriptlet('prevent-setTimeout', 'value', '300') ``` For instance, the following calls will be prevented: + ```javascript setTimeout(function () { window.test = "value"; @@ -1256,136 +1536,171 @@ and obviously it can not be matched by `matchCallback`. ``` [Scriptlet source](../src/scriptlets/prevent-setTimeout.js) + * * * -### ⚡️ prevent-window-open +## ⚡️ prevent-window-open -Prevents `window.open` calls when URL either matches or not matches the specified string/regexp. Using it without parameters prevents all `window.open` calls. +> Added in v1.0.4. + +Prevents `window.open` calls when URL either matches or not matches the specified string/regexp. +Using it without parameters prevents all `window.open` calls. Related UBO scriptlet: https://github.com/gorhill/uBlock/wiki/Resources-Library#windowopen-defuserjs- -**Syntax** -``` +### Syntax + +```text example.org#%#//scriptlet('prevent-window-open'[, match[, delay[, replacement]]]) ``` -- `match` — optional, string or regular expression. If not set or regular expression is invalid, all window.open calls will be matched. -If starts with `!`, scriptlet will not match the stringified callback but all other will be defused. -If do not start with `!`, the stringified callback will be matched. +- `match` — optional, string or regular expression. + If not set or regular expression is invalid, all window.open calls will be matched. + If starts with `!`, scriptlet will not match the stringified callback but all other will be defused. + If do not start with `!`, the stringified callback will be matched. - `delay` — optional, number of seconds. If not set, scriptlet will return `null`, -otherwise valid sham window object as injected `iframe` will be returned -for accessing its methods (blur(), focus() etc.) and will be removed after the delay. + otherwise valid sham window object as injected `iframe` will be returned + for accessing its methods (blur(), focus() etc.) and will be removed after the delay. - `replacement` — optional, string; one of the predefined constants: - `obj` — for returning an object instead of default iframe; for cases when the page requires a valid `window` instance to be returned - - `log` — for logging window.open calls; permitted for production filter lists. + - `log` — for logging window.open calls; not allowed for prod versions of filter lists. -**Examples** -1. Prevent all `window.open` calls: - ``` +### Examples + +1. Prevent all `window.open` calls + + ```adblock example.org#%#//scriptlet('prevent-window-open') ``` -2. Prevent `window.open` for all URLs containing `example`: - ``` +1. Prevent `window.open` for all URLs containing `example` + + ```adblock example.org#%#//scriptlet('prevent-window-open', 'example') ``` -3. Prevent `window.open` for all URLs matching RegExp `/example\./`: - ``` +1. Prevent `window.open` for all URLs matching RegExp `/example\./` + + ```adblock example.org#%#//scriptlet('prevent-window-open', '/example\./') ``` -4. Prevent `window.open` for all URLs **NOT** containing `example`: - ``` +1. Prevent `window.open` for all URLs **NOT** containing `example` + + ```adblock example.org#%#//scriptlet('prevent-window-open', '!example') ``` -Old syntax of prevent-window-open parameters: -- `match` — optional, defaults to "matching", any positive number or nothing for "matching", 0 or empty string for "not matching" -- `search` — optional, string or regexp for matching the URL passed to `window.open` call; defaults to search all `window.open` call -- `replacement` — optional, string to return prop value or property instead of window.open; defaults to return noopFunc. -**Examples** - ``` - example.org#%#//scriptlet('prevent-window-open', '1', '/example\./') - example.org#%#//scriptlet('prevent-window-open', '0', 'example') - example.org#%#//scriptlet('prevent-window-open', '', '', 'trueFunc') - example.org#%#//scriptlet('prevent-window-open', '1', '', '{propName=noopFunc}') - ``` +### Old syntax of prevent-window-open parameters + +- `match` — optional, defaults to "matching", any positive number or nothing for "matching", + 0 or empty string for "not matching" +- `search` — optional, string or regexp for matching the URL passed to `window.open` call; + defaults to search all `window.open` call +- `replacement` — optional, string to return prop value or property instead of window.open; + defaults to return noopFunc. + +### Examples of old syntax + +```adblock +example.org#%#//scriptlet('prevent-window-open', '1', '/example\./') +example.org#%#//scriptlet('prevent-window-open', '0', 'example') +example.org#%#//scriptlet('prevent-window-open', '', '', 'trueFunc') +example.org#%#//scriptlet('prevent-window-open', '1', '', '{propName=noopFunc}') +``` > For better compatibility with uBO, old syntax is not recommended to use. [Scriptlet source](../src/scriptlets/prevent-window-open.js) + * * * -### ⚡️ prevent-xhr +## ⚡️ prevent-xhr + +> Added in v1.5.0. Prevents `xhr` calls if **all** given parameters match. Related UBO scriptlet: https://github.com/gorhill/uBlock/wiki/Resources-Library#no-xhr-ifjs- -**Syntax** -``` +### Syntax + +```text example.org#%#//scriptlet('prevent-xhr'[, propsToMatch[, randomize]]) ``` - `propsToMatch` — optional, string of space-separated properties to match; possible props: - - string or regular expression for matching the URL passed to `XMLHttpRequest.open()` call; empty string or wildcard `*` for all `XMLHttpRequest.open()` calls match - - colon-separated pairs `name:value` where - - `name` is XMLHttpRequest object property name - - `value` is string or regular expression for matching the value of the option passed to `XMLHttpRequest.open()` call -- `randomize` — defaults to `false` for empty responseText, optional argument to randomize responseText of matched XMLHttpRequest's response; possible values: - - `true` to randomize responseText, random alphanumeric string of 10 symbols - - colon-separated pair `name:value` string value to customize responseText data where - - `name` — only `length` supported for now - - `value` — range on numbers, for example `100-300`, limited to 500000 characters + - string or regular expression for matching the URL passed to `XMLHttpRequest.open()` call; + empty string or wildcard `*` for all `XMLHttpRequest.open()` calls match + - colon-separated pairs `name:value` where + - `name` is XMLHttpRequest object property name + - `value` is string or regular expression for matching the value of the option + passed to `XMLHttpRequest.open()` call +- `randomize` — defaults to `false` for empty responseText, + optional argument to randomize responseText of matched XMLHttpRequest's response; possible values: + - `true` to randomize responseText, random alphanumeric string of 10 symbols + - colon-separated pair `name:value` string value to customize responseText data where + - `name` — only `length` supported for now + - `value` — range on numbers, for example `100-300`, limited to 500000 characters > Usage with no arguments will log XMLHttpRequest objects to browser console; -which is useful for debugging but not allowed for production filter lists. +> it may be useful for debugging but it is not allowed for prod versions of filter lists. + +### Examples -**Examples** 1. Log all XMLHttpRequests - ``` + + ```adblock example.org#%#//scriptlet('prevent-xhr') ``` -2. Prevent all XMLHttpRequests - ``` +1. Prevent all XMLHttpRequests + + ```adblock example.org#%#//scriptlet('prevent-xhr', '*') example.org#%#//scriptlet('prevent-xhr', '') ``` -3. Prevent XMLHttpRequests for specific url - ``` +1. Prevent XMLHttpRequests for specific url + + ```adblock example.org#%#//scriptlet('prevent-xhr', 'example.org') ``` -4. Prevent XMLHttpRequests for specific request method - ``` +1. Prevent XMLHttpRequests for specific request method + + ```adblock example.org#%#//scriptlet('prevent-xhr', 'method:HEAD') ``` -5. Prevent XMLHttpRequests for specific url and specified request methods - ``` +1. Prevent XMLHttpRequests for specific url and specified request methods + + ```adblock example.org#%#//scriptlet('prevent-xhr', 'example.org method:/HEAD|GET/') ``` -6. Prevent XMLHttpRequests for specific url and randomize it's response text - ``` +1. Prevent XMLHttpRequests for specific url and randomize it's response text + + ```adblock example.org#%#//scriptlet('prevent-xhr', 'example.org', 'true') ``` -7. Prevent XMLHttpRequests for specific url and randomize it's response text with range - ``` +1. Prevent XMLHttpRequests for specific url and randomize it's response text with range + + ```adblock example.org#%#//scriptlet('prevent-xhr', 'example.org', 'length:100-300') ``` [Scriptlet source](../src/scriptlets/prevent-xhr.js) + * * * -### ⚡️ remove-attr +## ⚡️ remove-attr + +> Added in v1.0.4. Removes the specified attributes from DOM nodes. This scriptlet runs once when the page loads and after that periodically in order to DOM tree changes by default, @@ -1394,21 +1709,25 @@ or as specified by applying argument. Related UBO scriptlet: https://github.com/gorhill/uBlock/wiki/Resources-Library#remove-attrjs- -**Syntax** -``` +### Syntax + +```text example.org#%#//scriptlet('remove-attr', attrs[, selector, applying]) ``` - `attrs` — required, attribute or list of attributes joined by '|' - `selector` — optional, CSS selector, specifies DOM nodes from which the attributes will be removed -- `applying` — optional, one or more space-separated flags that describe the way scriptlet apply, defaults to 'asap stay'; possible flags: +- `applying` — optional, one or more space-separated flags that describe the way scriptlet apply, + defaults to 'asap stay'; possible flags: - `asap` — runs as fast as possible **once** - `complete` — runs **once** after the whole page has been loaded - `stay` — as fast as possible **and** stays on the page observing possible DOM changes -**Examples** -1. Removes by attribute - ``` +### Examples + +1. Removes by attribute + + ```adblock example.org#%#//scriptlet('remove-attr', 'example|test') ``` @@ -1420,8 +1739,9 @@ example.org#%#//scriptlet('remove-attr', attrs[, selector, applying])
Some text
``` -2. Removes with specified selector - ``` +1. Removes with specified selector + + ```adblock example.org#%#//scriptlet('remove-attr', 'example', 'div[class="inner"]') ``` @@ -1437,15 +1757,19 @@ example.org#%#//scriptlet('remove-attr', attrs[, selector, applying]) ``` - 3. Using flags - ``` +1. Using flags + + ```adblock example.org#%#//scriptlet('remove-attr', 'example', 'html', 'asap complete') ``` [Scriptlet source](../src/scriptlets/remove-attr.js) + * * * -### ⚡️ remove-class +## ⚡️ remove-class + +> Added in v1.1.1. Removes the specified classes from DOM nodes. This scriptlet runs once after the page loads and after that periodically in order to DOM tree changes. @@ -1453,22 +1777,26 @@ and after that periodically in order to DOM tree changes. Related UBO scriptlet: https://github.com/gorhill/uBlock/wiki/Resources-Library#remove-classjs- -**Syntax** -``` +### Syntax + +```text example.org#%#//scriptlet('remove-class', classes[, selector, applying]) ``` - `classes` — required, class or list of classes separated by '|' - `selector` — optional, CSS selector, specifies DOM nodes from which the classes will be removed. -If there is no `selector`, each class of `classes` independently will be removed from all nodes which has one -- `applying` — optional, one or more space-separated flags that describe the way scriptlet apply, defaults to 'asap stay'; possible flags: + If there is no `selector`, each class of `classes` independently will be removed from all nodes which has one +- `applying` — optional, one or more space-separated flags that describe the way scriptlet apply, + defaults to 'asap stay'; possible flags: - `asap` — runs as fast as possible **once** - `complete` — runs **once** after the whole page has been loaded - `stay` — as fast as possible **and** stays on the page observing possible DOM changes -**Examples** -1. Removes by classes - ``` +### Examples + +1. Removes by classes + + ```adblock example.org#%#//scriptlet('remove-class', 'example|test') ``` @@ -1484,8 +1812,9 @@ If there is no `selector`, each class of `classes` independently will be removed
Some text
``` -2. Removes with specified selector - ``` +1. Removes with specified selector + + ```adblock example.org#%#//scriptlet('remove-class', 'branding', 'div[class^="inner"]') ``` @@ -1501,36 +1830,49 @@ If there is no `selector`, each class of `classes` independently will be removed ``` - 3. Using flags - ``` +1. Using flags + + ```adblock example.org#%#//scriptlet('remove-class', 'branding', 'div[class^="inner"]', 'asap complete') ``` [Scriptlet source](../src/scriptlets/remove-class.js) + * * * -### ⚡️ remove-cookie +## ⚡️ remove-cookie -Removes current page cookies by passed string matching with name. For current domain and subdomains. Runs on load and before unload. +> Added in v1.0.4. + +Removes current page cookies by passed string matching with name. For current domain and subdomains. +Runs on load and before unload. Related UBO scriptlet: https://github.com/gorhill/uBlock/wiki/Resources-Library#cookie-removerjs- -**Syntax** -``` +Related ABP source: +https://gitlab.com/eyeo/snippets/-/blob/main/source/behavioral/cookie-remover.js + +### Syntax + +```text example.org#%#//scriptlet('remove-cookie'[, match]) ``` -- `match` — optional, string or regex matching the cookie name. If not specified all accessible cookies will be removed. +- `match` — optional, string or regex matching the cookie name. + If not specified all accessible cookies will be removed. -**Examples** -1. Removes all cookies: - ``` +### Examples + +1. Removes all cookies + + ```adblock example.org#%#//scriptlet('remove-cookie') ``` -2. Removes cookies which name contains `example` string: - ``` +1. Removes cookies which name contains `example` string + + ```adblock example.org#%#//scriptlet('remove-cookie', 'example') ``` @@ -1541,14 +1883,18 @@ example.org#%#//scriptlet('remove-cookie'[, match]) ``` [Scriptlet source](../src/scriptlets/remove-cookie.js) + * * * -### ⚡️ remove-in-shadow-dom +## ⚡️ remove-in-shadow-dom + +> Added in v1.3.14. Removes elements inside open shadow DOM elements. -**Syntax** -``` +### Syntax + +```text example.org#%#//scriptlet('remove-in-shadow-dom', selector[, baseSelector]) ``` @@ -1557,10 +1903,11 @@ example.org#%#//scriptlet('remove-in-shadow-dom', selector[, baseSelector]) narrows down the part of the page DOM where shadow-dom host supposed to be, defaults to document.documentElement -> `baseSelector` should match element of the page DOM, but not of shadow DOM +> `baseSelector` should match element of the page DOM, but not of shadow DOM. -**Examples** -``` +### Examples + +```adblock ! removes menu bar virustotal.com#%#//scriptlet('remove-in-shadow-dom', 'iron-pages', 'vt-virustotal-app') @@ -1569,15 +1916,77 @@ virustotal.com#%#//scriptlet('remove-in-shadow-dom', 'vt-ui-contact-fab') ``` [Scriptlet source](../src/scriptlets/remove-in-shadow-dom.js) + +* * * + +## ⚡️ remove-node-text + +> Added in unreleased. + +Removes text from DOM nodes. + +Related UBO scriptlet: +https://github.com/gorhill/uBlock/commit/2bb446797a12086f2eebc0c8635b671b8b90c477 + +### Syntax + +```adblock +example.org#%#//scriptlet('remove-node-text', nodeName, condition) +``` + +- `nodeName` — required, string or RegExp, specifies DOM node name from which the text will be removed. +Must target lowercased node names, e.g `div` instead of `DIV`. +- `textMatch` — required, string or RegExp to match against node's text content. +If matched, the whole text will be removed. Case sensitive. + +### Examples + +1. Remove node's text content: + + ```adblock + example.org#%#//scriptlet('remove-node-text', 'div', 'some text') + ``` + + ```html + +
some text
+ some text + + +
+ some text + ``` + +2. Remove node's text content, matching both node name and condition by RegExp: + + ```adblock + example.org#%#//scriptlet('remove-node-text', '/[a-z]*[0-9]/', '/text/') + ``` + + ```html + + some text + some text + + + + some text + ``` + +[Scriptlet source](../src/scriptlets/remove-node-text.js) + * * * -### ⚡️ set-attr +## ⚡️ set-attr + +> Added in v1.5.0. Sets the specified attribute on the specified elements. This scriptlet runs once when the page loads and after that and after that on DOM tree changes. -**Syntax** -``` +### Syntax + +```text example.org#%#//scriptlet('set-attr', selector, attr[, value]) ``` @@ -1588,9 +1997,11 @@ example.org#%#//scriptlet('set-attr', selector, attr[, value]) - positive decimal integer `<= 32767` - `true` / `false` in any case variation -**Examples** -1. Set attribute by selector - ``` +### Examples + +1. Set attribute by selector + + ```adblock example.org#%#//scriptlet('set-attr', 'div.class > a.class', 'test-attribute', '0') ``` @@ -1601,8 +2012,10 @@ example.org#%#//scriptlet('set-attr', selector, attr[, value]) Some text ``` -2. Set attribute without value - ``` + +1. Set attribute without value + + ```adblock example.org#%#//scriptlet('set-attr', 'div.class > a.class', 'test-attribute') ``` @@ -1613,8 +2026,10 @@ example.org#%#//scriptlet('set-attr', selector, attr[, value]) Some text ``` -3. Set attribute value to `TRUE` - ``` + +1. Set attribute value to `TRUE` + + ```adblock example.org#%#//scriptlet('set-attr', 'div.class > a.class', 'test-attribute', 'TRUE') ``` @@ -1625,8 +2040,10 @@ example.org#%#//scriptlet('set-attr', selector, attr[, value]) Some text ``` -4. Set attribute value to `fAlse` - ``` + +1. Set attribute value to `fAlse` + + ```adblock example.org#%#//scriptlet('set-attr', 'div.class > a.class', 'test-attribute', 'fAlse') ``` @@ -1639,9 +2056,12 @@ example.org#%#//scriptlet('set-attr', selector, attr[, value]) ``` [Scriptlet source](../src/scriptlets/set-attr.js) + * * * -### ⚡️ set-constant +## ⚡️ set-constant + +> Added in v1.0.4. Creates a constant property and assigns it one of the values from the predefined list. @@ -1655,8 +2075,9 @@ https://github.com/gorhill/uBlock/wiki/Resources-Library#set-constantjs- Related ABP snippet: https://github.com/adblockplus/adblockpluscore/blob/adblockpluschrome-3.9.4/lib/content/snippets.js#L1361 -**Syntax** -``` +### Syntax + +```text example.org#%#//scriptlet('set-constant', property, value[, stack]) ``` @@ -1681,18 +2102,24 @@ example.org#%#//scriptlet('set-constant', property, value[, stack]) - `-1` — number value `-1` - `yes` - `no` -- `stack` — optional, string or regular expression that must match the current function call stack trace; -if regular expression is invalid it will be skipped +- `stack` — string or regular expression that must match the current function call stack trace, + defaults to matching every call; if regular expression is invalid, it will be skipped +- `valueWrapper` – optional, string to modify a value to be set. Possible wrappers: + - `asFunction` – function returning value + - `asCallback` – function returning callback, that would return value + - `asResolved` – Promise that would resolve with value + - `asRejected` – Promise that would reject with value -**Examples** -``` +### Examples + +```adblock ! Any access to `window.first` will return `false` example.org#%#//scriptlet('set-constant', 'first', 'false') ✔ window.first === false ``` -``` +```adblock ! Any call to `window.second()` will return `true` example.org#%#//scriptlet('set-constant', 'second', 'trueFunc') @@ -1700,24 +2127,42 @@ example.org#%#//scriptlet('set-constant', 'second', 'trueFunc') ✔ window.second.toString() === "function trueFunc() {return true;}" ``` -``` +```adblock ! Any call to `document.third()` will return `true` if the method is related to `checking.js` example.org#%#//scriptlet('set-constant', 'document.third', 'trueFunc', 'checking.js') ✔ document.third() === true // if the condition described above is met ``` +```adblock +! Any call to `document.fourth()` will return `yes` +example.org#%#//scriptlet('set-constant', 'document.fourth', 'yes', '', 'asFunction') + +✔ document.fourth() === 'yes' +``` + +```adblock +! Any call to `document.fifth()` will return `yes` +example.org#%#//scriptlet('set-constant', 'document.fifth', '42', '', 'asRejected') + +✔ document.fifth.catch((reason) => reason === 42) // promise rejects with specified number +``` + [Scriptlet source](../src/scriptlets/set-constant.js) + * * * -### ⚡️ set-cookie-reload +## ⚡️ set-cookie-reload + +> Added in v1.3.14. Sets a cookie with the specified name and value, and path, and reloads the current page after the cookie setting. If reloading option is not needed, use [set-cookie](#set-cookie) scriptlet. -**Syntax** -``` +### Syntax + +```text example.org#%#//scriptlet('set-cookie-reload', name, value[, path]) ``` @@ -1734,8 +2179,12 @@ example.org#%#//scriptlet('set-cookie-reload', name, value[, path]) - `/` — root path - `none` — to set no path at all -**Examples** -``` +> Note that the scriptlet encodes cookie names and values, +> e.g value `"{ test: 'value'}"` becomes `%7B%20test%3A%20'value'%7D`. + +### Examples + +```adblock example.org#%#//scriptlet('set-cookie-reload', 'checking', 'ok') example.org#%#//scriptlet('set-cookie-reload', 'gdpr-settings-cookie', '1') @@ -1744,14 +2193,18 @@ example.org#%#//scriptlet('set-cookie-reload', 'cookie-set', 'true', 'none') ``` [Scriptlet source](../src/scriptlets/set-cookie-reload.js) + * * * -### ⚡️ set-cookie +## ⚡️ set-cookie + +> Added in v1.2.3. Sets a cookie with the specified name, value, and path. -**Syntax** -``` +### Syntax + +```text example.org#%#//scriptlet('set-cookie', name, value[, path]) ``` @@ -1768,8 +2221,12 @@ example.org#%#//scriptlet('set-cookie', name, value[, path]) - `/` — root path - `none` — to set no path at all -**Examples** -``` +> Note that the scriptlet encodes cookie names and values, +> e.g value `"{ test: 'value'}"` becomes `%7B%20test%3A%20'value'%7D`. + +### Examples + +```adblock example.org#%#//scriptlet('set-cookie', 'CookieConsent', '1') example.org#%#//scriptlet('set-cookie', 'gdpr-settings-cookie', 'true') @@ -1778,15 +2235,19 @@ example.org#%#//scriptlet('set-cookie', 'cookie_consent', 'ok', 'none') ``` [Scriptlet source](../src/scriptlets/set-cookie.js) + * * * -### ⚡️ set-local-storage-item +## ⚡️ set-local-storage-item + +> Added in v1.4.3. Adds specified key and its value to localStorage object, or updates the value of the key if it already exists. Scriptlet won't set item if storage is full. -**Syntax** -``` +### Syntax + +```text example.com#%#//scriptlet('set-local-storage-item', 'key', 'value') ``` @@ -1804,38 +2265,47 @@ example.com#%#//scriptlet('set-local-storage-item', 'key', 'value') - `yes` - `no` -**Examples** -``` +### Examples + +```adblock example.org#%#//scriptlet('set-local-storage-item', 'player.live.current.mute', 'false') example.org#%#//scriptlet('set-local-storage-item', 'exit-intent-marketing', '1') ``` [Scriptlet source](../src/scriptlets/set-local-storage-item.js) + * * * -### ⚡️ set-popads-dummy +## ⚡️ set-popads-dummy + +> Added in v1.0.4. Sets static properties PopAds and popns. Related UBO scriptlet: https://github.com/gorhill/uBlock/wiki/Resources-Library#popads-dummyjs- -**Syntax** -``` +### Syntax + +```adblock example.org#%#//scriptlet('set-popads-dummy') ``` [Scriptlet source](../src/scriptlets/set-popads-dummy.js) + * * * -### ⚡️ set-session-storage-item +## ⚡️ set-session-storage-item + +> Added in v1.4.3. Adds specified key and its value to sessionStorage object, or updates the value of the key if it already exists. Scriptlet won't set item if storage is full. -**Syntax** -``` +### Syntax + +```text example.com#%#//scriptlet('set-session-storage-item', 'key', 'value') ``` @@ -1853,57 +2323,137 @@ example.com#%#//scriptlet('set-session-storage-item', 'key', 'value') - `yes` - `no` -**Examples** -``` +### Examples + +```adblock example.org#%#//scriptlet('set-session-storage-item', 'player.live.current.mute', 'false') example.org#%#//scriptlet('set-session-storage-item', 'exit-intent-marketing', '1') ``` [Scriptlet source](../src/scriptlets/set-session-storage-item.js) + * * * -### ⚡️ xml-prune +## ⚡️ xml-prune + +> Added in 1.7.3. Removes an element from the specified XML. -**Syntax** -``` +Related UBO scriptlet: +https://github.com/gorhill/uBlock/wiki/Resources-Library#xml-prunejs- + +### Syntax + +```text example.org#%#//scriptlet('xml-prune'[, propsToMatch[, optionalProp[, urlToMatch]]]) ``` - `propsToMatch` — optional, selector of elements which will be removed from XML - `optionalProp` — optional, selector of elements that must occur in XML document - `urlToMatch` — optional, string or regular expression for matching the request's URL + > Usage with no arguments will log response payload and URL to browser console; -which is useful for debugging but prohibited for production filter lists. +> it may be useful for debugging but it is not allowed for prod versions of filter lists. + +### Examples -**Examples** 1. Remove `Period` tag whose `id` contains `-ad-` from all requests - ``` + + ```adblock example.org#%#//scriptlet('xml-prune', 'Period[id*="-ad-"]') ``` -2. Remove `Period` tag whose `id` contains `-ad-`, only if XML contains `SegmentTemplate` - ``` +1. Remove `Period` tag whose `id` contains `-ad-`, only if XML contains `SegmentTemplate` + + ```adblock example.org#%#//scriptlet('xml-prune', 'Period[id*="-ad-"]', 'SegmentTemplate') ``` -3. Remove `Period` tag whose `id` contains `-ad-`, only if request's URL contains `.mpd` - ``` +1. Remove `Period` tag whose `id` contains `-ad-`, only if request's URL contains `.mpd` + + ```adblock example.org#%#//scriptlet('xml-prune', 'Period[id*="-ad-"]', '', '.mpd') ``` -4. Call with no arguments will log response payload and URL at the console - ``` +1. Call with no arguments will log response payload and URL at the console + + ```adblock example.org#%#//scriptlet('xml-prune') ``` -5. Call with only `urlToMatch` argument will log response payload and URL only for the matched URL - ``` +1. Call with only `urlToMatch` argument will log response payload and URL only for the matched URL + + ```adblock example.org#%#//scriptlet('xml-prune', '', '', '.mpd') ``` [Scriptlet source](../src/scriptlets/xml-prune.js) + +* * * + +## ⚡️ trusted-replace-node-text + +> Added in unreleased. + +Replaces text in text content of matched DOM nodes. + +Related UBO scriptlet: +https://github.com/gorhill/uBlock/commit/41876336db48 + +### Syntax + +```adblock +example.org#%#//scriptlet('trusted-replace-node-text', nodeName, condition) +``` + +- `nodeName` — required, string or RegExp, specifies DOM node name from which the text will be removed. +Must target lowercased node names, e.g `div` instead of `DIV`. +- `textMatch` — required, string or RegExp to match against node's text content. +If matched, the whole text will be removed. Case sensitive. +- `pattern` — required, string or regexp for matching contents of `node.textContent` that should be replaced. +- `replacement` — required, string to replace text content matched by `pattern`. + +### Examples + +1. Replace node's text content: + + ```adblock + example.org#%#//scriptlet('trusted-replace-node-text', 'div', 'some', 'text', 'other text') + ``` + + ```html + +
some text
+
text
+ some text + + +
some other text
+
text
+ some text + ``` + +2. Replace node's text content, matching both node name, text and pattern by RegExp: + + ```adblock + example.org#%#//scriptlet('trusted-replace-node-text', '/[a-z]*[0-9]/', '/s\dme/', '/t\dxt/', 'other text') + ``` + + ```html + + s0me t3xt // this node is going to be matched by both node name and text + text // this node won't be matched by text content nor text content + some text + + + s0me other text // text content has changed + text + some text + ``` + +[Scriptlet source](../src/scriptlets/trusted-replace-node-text.js) + * * * diff --git a/wiki/about-trusted-scriptlets.md b/wiki/about-trusted-scriptlets.md index 656b6d92..44b3693f 100644 --- a/wiki/about-trusted-scriptlets.md +++ b/wiki/about-trusted-scriptlets.md @@ -1,189 +1,255 @@ -## Available Trusted Scriptlets -* [trusted-click-element](#trusted-click-element) -* [trusted-replace-fetch-response](#trusted-replace-fetch-response) -* [trusted-replace-xhr-response](#trusted-replace-xhr-response) -* [trusted-set-constant](#trusted-set-constant) -* [trusted-set-cookie-reload](#trusted-set-cookie-reload) -* [trusted-set-cookie](#trusted-set-cookie) -* [trusted-set-local-storage-item](#trusted-set-local-storage-item) +# Available Trusted Scriptlets + +- [trusted-click-element](#trusted-click-element) +- [trusted-replace-fetch-response](#trusted-replace-fetch-response) +- [trusted-replace-xhr-response](#trusted-replace-xhr-response) +- [trusted-set-constant](#trusted-set-constant) +- [trusted-set-cookie-reload](#trusted-set-cookie-reload) +- [trusted-set-cookie](#trusted-set-cookie) +- [trusted-set-local-storage-item](#trusted-set-local-storage-item) + * * * -### ⚡️ trusted-click-element -Clicks selected elements in a strict sequence, ordered by selectors passed, and waiting for them to render in the DOM first. +## ⚡️ trusted-click-element + +> Added in v1.7.3. + +Clicks selected elements in a strict sequence, ordered by selectors passed, +and waiting for them to render in the DOM first. Deactivates after all elements have been clicked or by 10s timeout. -**Syntax** -``` +### Syntax + +```text example.com#%#//scriptlet('trusted-click-element', selectors[, extraMatch[, delay]]) ``` - `selectors` — required, string with query selectors delimited by comma -- `extraMatch` — optional, extra condition to check on a page; allows to match `cookie` and `localStorage`; can be set as `name:key[=value]` where `value` is optional. -If `cookie`/`localStorage` starts with `!` then the element will only be clicked if specified cookie/localStorage item does not exist. -Multiple conditions are allowed inside one `extraMatch` but they should be delimited by comma and each of them should match the syntax. Possible `name`s: - - `cookie` - test string or regex against cookies on a page - - `localStorage` - check if localStorage item is present +- `extraMatch` — optional, extra condition to check on a page; allows to match `cookie` and `localStorage`; +can be set as `name:key[=value]` where `value` is optional. +If `cookie`/`localStorage` starts with `!` then the element will only be clicked +if specified cookie/localStorage item does not exist. +Multiple conditions are allowed inside one `extraMatch` but they should be delimited by comma +and each of them should match the syntax. Possible `name`s: + - `cookie` — test string or regex against cookies on a page + - `localStorage` — check if localStorage item is present - `delay` — optional, time in ms to delay scriptlet execution, defaults to instant execution. -**Examples** +### Examples + 1. Click single element by selector -``` -example.com#%#//scriptlet('trusted-click-element', 'button[name="agree"]') -``` -2. Delay click execution by 500ms -``` -example.com#%#//scriptlet('trusted-click-element', 'button[name="agree"]', '', '500') -``` + ```adblock + example.com#%#//scriptlet('trusted-click-element', 'button[name="agree"]') + ``` -3. Click multiple elements by selector with a delay -``` -example.com#%#//scriptlet('trusted-click-element', 'button[name="agree"], button[name="check"], input[type="submit"][value="akkoord"]', '', '500') -``` +1. Delay click execution by 500ms -4. Match cookies by keys using regex and string -``` -example.com#%#//scriptlet('trusted-click-element', 'button[name="agree"]', 'cookie:userConsentCommunity, cookie:/cmpconsent|cmp/') -``` + ```adblock + example.com#%#//scriptlet('trusted-click-element', 'button[name="agree"]', '', '500') + ``` -5. Match by cookie key=value pairs using regex and string -``` -example.com#%#//scriptlet('trusted-click-element', 'button[name="agree"]', 'cookie:userConsentCommunity=true, cookie:/cmpconsent|cmp/=/[a-z]{1,5}/') -``` +1. Click multiple elements by selector with a delay -6. Match by localStorage item 'promo' key -``` -example.com#%#//scriptlet('trusted-click-element', 'button[name="agree"]', 'localStorage:promo') -``` + -7. Click multiple elements with delay and matching by both cookie string and localStorage item -``` -example.com#%#//scriptlet('trusted-click-element', 'button[name="agree"], input[type="submit"][value="akkoord"]', 'cookie:cmpconsent, localStorage:promo', '250') -``` + ```adblock + example.com#%#//scriptlet('trusted-click-element', 'button[name="agree"], button[name="check"], input[type="submit"][value="akkoord"]', '', '500') + ``` -8. Click element only if cookie with name `cmpconsent` does not exist -``` -example.com#%#//scriptlet('trusted-click-element', 'button[name="agree"]', '!cookie:cmpconsent') -``` +1. Match cookies by keys using regex and string -9. Click element only if specified cookie string and localStorage item does not exist -``` -example.com#%#//scriptlet('trusted-click-element', 'button[name="agree"]', '!cookie:cmpconsent, !localStorage:promo') -``` + ```adblock + example.com#%#//scriptlet('trusted-click-element', 'button[name="agree"]', 'cookie:userConsentCommunity, cookie:/cmpconsent|cmp/') + ``` + +1. Match by cookie key=value pairs using regex and string + + ```adblock + example.com#%#//scriptlet('trusted-click-element', 'button[name="agree"]', 'cookie:userConsentCommunity=true, cookie:/cmpconsent|cmp/=/[a-z]{1,5}/') + ``` + +1. Match by localStorage item 'promo' key + + ```adblock + example.com#%#//scriptlet('trusted-click-element', 'button[name="agree"]', 'localStorage:promo') + ``` + +1. Click multiple elements with delay and matching by both cookie string and localStorage item + + ```adblock + example.com#%#//scriptlet('trusted-click-element', 'button[name="agree"], input[type="submit"][value="akkoord"]', 'cookie:cmpconsent, localStorage:promo', '250') + ``` + + + +1. Click element only if cookie with name `cmpconsent` does not exist + + ```adblock + example.com#%#//scriptlet('trusted-click-element', 'button[name="agree"]', '!cookie:cmpconsent') + ``` + +1. Click element only if specified cookie string and localStorage item does not exist + + ```adblock + example.com#%#//scriptlet('trusted-click-element', 'button[name="agree"]', '!cookie:consent, !localStorage:promo') + ``` [Scriptlet source](../src/scriptlets/trusted-click-element.js) + * * * -### ⚡️ trusted-replace-fetch-response +## ⚡️ trusted-replace-fetch-response + +> Added in v1.7.3. Replaces response text content of `fetch` requests if **all** given parameters match. -**Syntax** -``` +### Syntax + +```text example.org#%#//scriptlet('trusted-replace-fetch-response'[, pattern, replacement[, propsToMatch]]) ``` -- `pattern` — optional, argument for matching contents of responseText that should be replaced. If set, `replacement` is required; -possible values: - - `*` to match all text content - - non-empty string - - regular expression -- `replacement` — optional, should be set if `pattern` is set. String to replace the response text content matched by `pattern`. -Empty string to remove content. Defaults to empty string. +- `pattern` — optional, argument for matching contents of responseText that should be replaced. +If set, `replacement` is required. Possible values: + - `*` to match all text content + - non-empty string + - regular expression +- `replacement` — optional, should be set if `pattern` is set. String to replace the response text content + matched by `pattern`. Empty string to remove content. Defaults to empty string. - `propsToMatch` — optional, string of space-separated properties to match; possible props: - - string or regular expression for matching the URL passed to fetch call; empty string, wildcard `*` or invalid regular expression will match all fetch calls - - colon-separated pairs `name:value` where - - `name` is [`init` option name](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch#parameters) - - `value` is string or regular expression for matching the value of the option passed to fetch call; invalid regular expression will cause any value matching + - string or regular expression for matching the URL passed to fetch call; + empty string, wildcard `*` or invalid regular expression will match all fetch calls + - colon-separated pairs `name:value` where + + - `name` is [`init` option name](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch#parameters) + - `value` is string or regular expression for matching the value of the option passed to fetch call; + invalid regular expression will cause any value matching > Usage with no arguments will log fetch calls to browser console; -which is useful for debugging but only allowed for production filter lists. +> it may be useful for debugging but it is not allowed for prod versions of filter lists. > Scriptlet does nothing if response body can't be converted to text. -**Examples** +### Examples + 1. Log all fetch calls - ``` + + ```adblock example.org#%#//scriptlet('trusted-replace-fetch-response') ``` -2. Replace response text content of fetch requests with specific url - ``` +1. Replace response text content of fetch requests with specific url + + + + ```adblock example.org#%#//scriptlet('trusted-replace-fetch-response', 'adb_detect:true', 'adb_detect:false', 'example.org') example.org#%#//scriptlet('trusted-replace-fetch-response', '/#EXT-X-VMAP-AD-BREAK[\s\S]*?/', '#EXT-X-ENDLIST', 'example.org') ``` -3. Remove all text content of fetch responses with specific request method - ``` + + +1. Remove all text content of fetch responses with specific request method + + ```adblock example.org#%#//scriptlet('trusted-replace-fetch-response', '*', '', 'method:GET') ``` -4. Replace response text content of fetch requests matching by URL regex and request methods - ``` +1. Replace response text content of fetch requests matching by URL regex and request methods + + + + ```adblock example.org#%#//scriptlet('trusted-replace-fetch-response', '/#EXT-X-VMAP-AD-BREAK[\s\S]*?/', '#EXT-X-ENDLIST', '/\.m3u8/ method:/GET|HEAD/') ``` -5. Remove text content of all fetch responses for example.com - ``` + + + +1. Remove text content of all fetch responses for example.com + + ```adblock example.org#%#//scriptlet('trusted-replace-fetch-response', '*', '', 'example.com') ``` [Scriptlet source](../src/scriptlets/trusted-replace-fetch-response.js) + * * * -### ⚡️ trusted-replace-xhr-response +## ⚡️ trusted-replace-xhr-response + +> Added in v1.7.3. Replaces response content of `xhr` requests if **all** given parameters match. -**Syntax** -``` +### Syntax + +```text example.org#%#//scriptlet('trusted-replace-xhr-response'[, pattern, replacement[, propsToMatch]]) ``` -- `pattern` — optional, argument for matching contents of responseText that should be replaced. If set, `replacement` is required; -possible values: - - `*` to match all text content - - non-empty string - - regular expression -- `replacement` — optional, should be set if `pattern` is set. String to replace matched content with. Empty string to remove content. +- `pattern` — optional, argument for matching contents of responseText that should be replaced. + If set, `replacement` is required. Possible values: + - `*` to match all text content + - non-empty string + - regular expression +- `replacement` — optional, should be set if `pattern` is set. String to replace matched content with. + Empty string to remove content. - `propsToMatch` — optional, string of space-separated properties to match for extra condition; possible props: - - string or regular expression for matching the URL passed to `XMLHttpRequest.open()` call; - - colon-separated pairs `name:value` where - - `name` — string or regular expression for matching XMLHttpRequest property name - - `value` — string or regular expression for matching the value of the option passed to `XMLHttpRequest.open()` call + - string or regular expression for matching the URL passed to `XMLHttpRequest.open()` call; + - colon-separated pairs `name:value` where + - `name` — string or regular expression for matching XMLHttpRequest property name + - `value` — string or regular expression for matching the value of the option + passed to `XMLHttpRequest.open()` call > Usage with no arguments will log XMLHttpRequest objects to browser console; -which is useful for debugging but not permitted for production filter lists. +> it may be useful for debugging but it is not allowed for prod versions of filter lists. + +### Examples -**Examples** 1. Log all XMLHttpRequests - ``` + + ```adblock example.org#%#//scriptlet('trusted-replace-xhr-response') ``` -2. Replace text content of XMLHttpRequests with specific url - ``` +1. Replace text content of XMLHttpRequests with specific url + + + + ```adblock example.org#%#//scriptlet('trusted-replace-xhr-response', 'adb_detect:true', 'adb_detect:false', 'example.org') example.org#%#//scriptlet('trusted-replace-xhr-response', '/#EXT-X-VMAP-AD-BREAK[\s\S]*?/', '#EXT-X-ENDLIST', 'example.org') ``` -3. Remove all text content of XMLHttpRequests with specific request method - ``` + + +1. Remove all text content of XMLHttpRequests with specific request method + + ```adblock example.org#%#//scriptlet('trusted-replace-xhr-response', '*', '', 'method:GET') ``` -4. Replace text content of XMLHttpRequests matching by URL regex and request methods - ``` - example.org#%#//scriptlet('trusted-replace-xhr-response', '/#EXT-X-VMAP-AD-BREAK[\s\S]*?/', '#EXT-X-ENDLIST', '/\.m3u8/ method:/GET|HEAD/') - ``` -5. Remove all text content of all XMLHttpRequests for example.com +1. Replace text content of XMLHttpRequests matching by URL regex and request methods + + ```adblock + example.org#%#//scriptlet('trusted-replace-xhr-response', '/#EXT-X-VMAP-AD-BREAK[\s\S]*?/', '#EXT-X-ENDLIST', '/\.m3u8/ method:/GET|HEAD/') ``` + +1. Remove all text content of all XMLHttpRequests for example.com + + ```adblock example.org#%#//scriptlet('trusted-replace-xhr-response', '*', '', 'example.com') ``` [Scriptlet source](../src/scriptlets/trusted-replace-xhr-response.js) + * * * -### ⚡️ trusted-set-constant +## ⚡️ trusted-set-constant + +> Added in v1.8.2. Creates a constant property and assigns it a specified value. @@ -193,208 +259,251 @@ Creates a constant property and assigns it a specified value. > Use [set-constant](./about-scriptlets.md#set-constant) to set predefined values and functions. -**Syntax** -``` +### Syntax + +```text example.org#%#//scriptlet('trusted-set-constant', property, value[, stack]) ``` - `property` — required, path to a property (joined with `.` if needed). The property must be attached to `window`. -- `value` — required, an arbitrary value to be set; value type is being inferred from the argument, e.g '500' will be set as number; -to set string type value wrap argument into another pair of quotes: `'"500"'`; +- `value` — required, an arbitrary value to be set; value type is being inferred from the argument, + e.g '500' will be set as number; to set string type value wrap argument into another pair of quotes: `'"500"'`; - `stack` — optional, string or regular expression that must match the current function call stack trace; -if regular expression is invalid it will be skipped + if regular expression is invalid it will be skipped + +### Examples -**Examples** 1. Set property values of different types -``` -! Set string value wrapping argument into another pair of quotes -example.org#%#//scriptlet('trusted-set-constant', 'click_r', '"null"') -✔ window.click_r === 'null' -✔ typeof window.click_r === 'string' + ```adblock + ! Set string value wrapping argument into another pair of quotes + example.org#%#//scriptlet('trusted-set-constant', 'click_r', '"null"') -! Set inferred null value -example.org#%#//scriptlet('trusted-set-constant', 'click_r', 'null') + ✔ window.click_r === 'null' + ✔ typeof window.click_r === 'string' -✔ window.click_r === null -✔ typeof window.click_r === 'object' + ! Set inferred null value + example.org#%#//scriptlet('trusted-set-constant', 'click_r', 'null') -! Set number type value -example.org#%#//scriptlet('trusted-set-constant', 'click_r', '48') + ✔ window.click_r === null + ✔ typeof window.click_r === 'object' -✔ window.click_r === 48 -✔ typeof window.click_r === 'number' + ! Set number type value + example.org#%#//scriptlet('trusted-set-constant', 'click_r', '48') -! Set array or object as property value, argument should be a JSON string -example.org#%#//scriptlet('trusted-set-constant', 'click_r', '[1,"string"]') -example.org#%#//scriptlet('trusted-set-constant', 'click_r', '{"aaa":123,"bbb":{"ccc":"string"}}') -``` + ✔ window.click_r === 48 + ✔ typeof window.click_r === 'number' -2. Use script stack matching to set value -``` -! `document.first` will return `1` if the method is related to `checking.js` -example.org#%#//scriptlet('trusted-set-constant', 'document.first', '1', 'checking.js') + ! Set array or object as property value, argument should be a JSON string + example.org#%#//scriptlet('trusted-set-constant', 'click_r', '[1,"string"]') + example.org#%#//scriptlet('trusted-set-constant', 'click_r', '{"aaa":123,"bbb":{"ccc":"string"}}') + ``` -✔ document.first === 1 // if the condition described above is met -``` +1. Use script stack matching to set value + + ```adblock + ! `document.first` will return `1` if the method is related to `checking.js` + example.org#%#//scriptlet('trusted-set-constant', 'document.first', '1', 'checking.js') + + ✔ document.first === 1 // if the condition described above is met + ``` [Scriptlet source](../src/scriptlets/trusted-set-constant.js) + * * * -### ⚡️ trusted-set-cookie-reload +## ⚡️ trusted-set-cookie-reload + +> Added in v1.7.10. Sets a cookie with arbitrary name and value, and with optional ability to offset cookie attribute 'expires' and set path. Also reloads the current page after the cookie setting. If reloading option is not needed, use the [`trusted-set-cookie` scriptlet](#trusted-set-cookie). -**Syntax** -``` +### Syntax + +```text example.org#%#//scriptlet('trusted-set-cookie-reload', name, value[, offsetExpiresSec[, path]]) ``` - `name` — required, cookie name to be set - `value` — required, cookie value. Possible values: - - arbitrary value - - empty string for no value - - `$now$` keyword for setting current time in ms, e.g 1667915146503 - - `$currentDate$` keyword for setting current time as string, e.g 'Tue Nov 08 2022 13:53:19 GMT+0300' -- `offsetExpiresSec` — optional, offset from current time in seconds, after which cookie should expire; defaults to no offset -Possible values: - - positive integer in seconds - - `1year` keyword for setting expiration date to one year - - `1day` keyword for setting expiration date to one day + - arbitrary value + - empty string for no value + - `$now$` keyword for setting current time in ms, e.g 1667915146503 + - `$currentDate$` keyword for setting current time as string, e.g 'Tue Nov 08 2022 13:53:19 GMT+0300' +- `offsetExpiresSec` — optional, offset from current time in seconds, after which cookie should expire; + defaults to no offset. Possible values: + - positive integer in seconds + - `1year` keyword for setting expiration date to one year + - `1day` keyword for setting expiration date to one day - `path` — optional, argument for setting cookie path, defaults to `/`; possible values: - - `/` — root path - - `none` — to set no path at all + - `/` — root path + - `none` — to set no path at all + +> Note that the scriptlet does not encode cookie names and values. +> As a result, if a cookie's name or value includes `;`, +> the scriptlet will not set the cookie since this may cause the cookie to break. + +### Examples -**Examples** 1. Set cookie and reload the page after it -``` -example.org#%#//scriptlet('trusted-set-cookie-reload', 'cmpconsent', 'accept') -``` -2. Set cookie with `new Date().getTime()` value and reload the page after it -``` -example.org#%#//scriptlet('trusted-set-cookie-reload', 'cmpconsent', '$now$') -``` + ```adblock + example.org#%#//scriptlet('trusted-set-cookie-reload', 'cmpconsent', 'accept') + ``` -3. Set cookie which will expire in 3 days and reload the page after it -``` -example.org#%#//scriptlet('trusted-set-cookie-reload', 'cmpconsent', 'accept', '259200') -``` +1. Set cookie with `new Date().getTime()` value and reload the page after it -4. Set cookie which will expire in one year and reload the page after it -``` -example.org#%#//scriptlet('trusted-set-cookie-reload', 'cmpconsent', 'accept', '1year') -``` + ```adblock + example.org#%#//scriptlet('trusted-set-cookie-reload', 'cmpconsent', '$now$') + ``` -5. Set cookie with no 'expire' and no path, reload the page after it -``` -example.org#%#//scriptlet('trusted-set-cookie-reload', 'cmpconsent', 'decline', '', 'none') -``` +1. Set cookie which will expire in 3 days and reload the page after it + + ```adblock + example.org#%#//scriptlet('trusted-set-cookie-reload', 'cmpconsent', 'accept', '259200') + ``` + +1. Set cookie which will expire in one year and reload the page after it + + ```adblock + example.org#%#//scriptlet('trusted-set-cookie-reload', 'cmpconsent', 'accept', '1year') + ``` + +1. Set cookie with no 'expire' and no path, reload the page after it + + ```adblock + example.org#%#//scriptlet('trusted-set-cookie-reload', 'cmpconsent', 'decline', '', 'none') + ``` [Scriptlet source](../src/scriptlets/trusted-set-cookie-reload.js) + * * * -### ⚡️ trusted-set-cookie +## ⚡️ trusted-set-cookie + +> Added in v1.7.3. Sets a cookie with arbitrary name and value, and with optional ability to offset cookie attribute 'expires' and set path. -**Syntax** -``` +### Syntax + +```text example.org#%#//scriptlet('trusted-set-cookie', name, value[, offsetExpiresSec[, path]]) ``` - `name` — required, cookie name to be set - `value` — required, cookie value. Possible values: - - arbitrary value - - empty string for no value - - `$now$` keyword for setting current time in ms, e.g 1667915146503 - - `$currentDate$` keyword for setting current time as string, e.g 'Tue Nov 08 2022 13:53:19 GMT+0300' -- `offsetExpiresSec` — optional, offset from current time in seconds, after which cookie should expire; defaults to no offset -Possible values: - - positive integer in seconds - - `1year` keyword for setting expiration date to one year - - `1day` keyword for setting expiration date to one day + - arbitrary value + - empty string for no value + - `$now$` keyword for setting current time in ms, e.g 1667915146503 + - `$currentDate$` keyword for setting current time as string, e.g 'Tue Nov 08 2022 13:53:19 GMT+0300' +- `offsetExpiresSec` — optional, offset from current time in seconds, after which cookie should expire; + defaults to no offset. Possible values: + - positive integer in seconds + - `1year` keyword for setting expiration date to one year + - `1day` keyword for setting expiration date to one day - `path` — optional, argument for setting cookie path, defaults to `/`; possible values: - - `/` — root path - - `none` — to set no path at all + - `/` — root path + - `none` — to set no path at all + +> Note that the scriptlet does not encode cookie names and values. +> As a result, if a cookie's name or value includes `;`, +> the scriptlet will not set the cookie since this may cause the cookie to break. + +### Examples -**Examples** 1. Set cookie -``` -example.org#%#//scriptlet('trusted-set-cookie', 'cmpconsent', 'accept') -example.org#%#//scriptlet('trusted-set-cookie', 'cmpconsent', '1-accept_1') -``` -2. Set cookie with `new Date().getTime()` value -``` -example.org#%#//scriptlet('trusted-set-cookie', 'cmpconsent', '$now$') -``` + ```adblock + example.org#%#//scriptlet('trusted-set-cookie', 'cmpconsent', 'accept') + example.org#%#//scriptlet('trusted-set-cookie', 'cmpconsent', '1-accept_1') + ``` -3. Set cookie which will expire in 3 days -``` -example.org#%#//scriptlet('trusted-set-cookie', 'cmpconsent', 'accept', '259200') -``` +1. Set cookie with `new Date().getTime()` value -4. Set cookie which will expire in one year -``` -example.org#%#//scriptlet('trusted-set-cookie', 'cmpconsent', 'accept', '1year') -``` + ```adblock + example.org#%#//scriptlet('trusted-set-cookie', 'cmpconsent', '$now$') + ``` -5. Set cookie with no path -``` -example.org#%#//scriptlet('trusted-set-cookie', 'cmpconsent', 'decline', '', 'none') -``` +1. Set cookie which will expire in 3 days + + ```adblock + example.org#%#//scriptlet('trusted-set-cookie', 'cmpconsent', 'accept', '259200') + ``` + +1. Set cookie which will expire in one year + + ```adblock + example.org#%#//scriptlet('trusted-set-cookie', 'cmpconsent', 'accept', '1year') + ``` + +1. Set cookie with no path + + ```adblock + example.org#%#//scriptlet('trusted-set-cookie', 'cmpconsent', 'decline', '', 'none') + ``` [Scriptlet source](../src/scriptlets/trusted-set-cookie.js) + * * * -### ⚡️ trusted-set-local-storage-item +## ⚡️ trusted-set-local-storage-item + +> Added in v1.7.3. Adds item with arbitrary key and value to localStorage object, or updates the value of the key if it already exists. Scriptlet won't set item if storage is full. -**Syntax** -``` +### Syntax + +```adblock example.com#%#//scriptlet('trusted-set-local-storage-item', 'key', 'value') ``` - `key` — required, key name to be set. - `value` — required, key value; possible values: - - arbitrary value - - `$now$` keyword for setting current time in ms, corresponds to `Date.now()` and `(new Date).getTime()` calls - - `$currentDate$` keyword for setting string representation of the current date and time, corresponds to `Date()` and `(new Date).toString()` calls + - arbitrary value + - `$now$` keyword for setting current time in ms, corresponds to `Date.now()` and `(new Date).getTime()` calls + - `$currentDate$` keyword for setting string representation of the current date and time, + corresponds to `Date()` and `(new Date).toString()` calls + +### Examples -**Examples** 1. Set local storage item -``` -example.org#%#//scriptlet('trusted-set-local-storage-item', 'player.live.current.mute', 'false') -example.org#%#//scriptlet('trusted-set-local-storage-item', 'COOKIE_CONSENTS', '{"preferences":3,"marketing":false}') + ```adblock + example.org#%#//scriptlet('trusted-set-local-storage-item', 'player.live.current.mute', 'false') -example.org#%#//scriptlet('trusted-set-local-storage-item', 'providers', '[16364,88364]') + example.org#%#//scriptlet('trusted-set-local-storage-item', 'COOKIE_CONSENTS', '{"preferences":3,"flag":false}') -example.org#%#//scriptlet('trusted-set-local-storage-item', 'providers', '{"providers":[16364,88364],"consent":"all"}') -``` + example.org#%#//scriptlet('trusted-set-local-storage-item', 'providers', '[16364,88364]') -2. Set item with current time since unix epoch in ms -``` -example.org#%#//scriptlet('trusted-set-local-storage-item', 'player.live.current.play', '$now$') -``` + example.org#%#//scriptlet('trusted-set-local-storage-item', 'providers', '{"providers":[123,456],"consent":"all"}') + ``` -3. Set item with current date, e.g 'Tue Nov 08 2022 13:53:19 GMT+0300' -``` -example.org#%#//scriptlet('trusted-set-local-storage-item', 'player.live.current.play', '$currentDate$') -``` +1. Set item with current time since unix epoch in ms -4. Set item without value -``` -example.org#%#//scriptlet('trusted-set-local-storage-item', 'ppu_main_none', '') -``` + ```adblock + example.org#%#//scriptlet('trusted-set-local-storage-item', 'player.live.current.play', '$now$') + ``` + +1. Set item with current date, e.g 'Tue Nov 08 2022 13:53:19 GMT+0300' + + ```adblock + example.org#%#//scriptlet('trusted-set-local-storage-item', 'player.live.current.play', '$currentDate$') + ``` + +1. Set item without value + + ```adblock + example.org#%#//scriptlet('trusted-set-local-storage-item', 'ppu_main_none', '') + ``` [Scriptlet source](../src/scriptlets/trusted-set-local-storage-item.js) + * * * diff --git a/wiki/compatibility-table.md b/wiki/compatibility-table.md index 5f9b50f3..8aa1788f 100644 --- a/wiki/compatibility-table.md +++ b/wiki/compatibility-table.md @@ -1,4 +1,10 @@ -# Scriptlets compatibility table +# Scriplets and Redirects compatibility tables + +- [Scriptlets](#scriptlets) +- [Redirects](#redirects) + + +## Scriptlets compatibility table | AdGuard | uBO | Adblock Plus | |---|---|---| @@ -12,7 +18,7 @@ | [debug-current-inline-script](../wiki/about-scriptlets.md#debug-current-inline-script) | | | | [debug-on-property-read](../wiki/about-scriptlets.md#debug-on-property-read) | | | | [debug-on-property-write](../wiki/about-scriptlets.md#debug-on-property-write) | | | -| [dir-string](../wiki/about-scriptlets.md#dir-string) | | dir-string | +| [dir-string](../wiki/about-scriptlets.md#dir-string) | | | | [disable-newtab-links](../wiki/about-scriptlets.md#disable-newtab-links) | disable-newtab-links.js | | | [json-prune](../wiki/about-scriptlets.md#json-prune) | json-prune.js | json-prune | | [log](../wiki/about-scriptlets.md#log) | | log | @@ -75,9 +81,14 @@ | | | abort-on-iframe-property-write | | | no-floc.js (removed) | | | | window.name-defuser.js | | +| | spoof-css.js | | +| | remove-node-text.js (rmnt.js) | | +| | replace-node-text.js (rpnt.js, sed.js) | | +| | trusted-set-constant.js (trusted-set.js) | | +| | evaldata-prune.js | | -# Redirects compatibility table +## Redirects compatibility table | AdGuard | uBO | Adblock Plus | |---|---|---|