diff --git a/src/scriptlets/remove-node-text.js b/src/scriptlets/remove-node-text.js index b37d006fd..47d99c47e 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 1e7f081e7..c4ee7fed1 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 e446ff986..e015ecc4b 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 687395125..72cddf89f 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])