diff --git a/CHANGELOG.md b/CHANGELOG.md index 6c1499367..789b6f20c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Scriptlets and Redirect Resources Changelog -## v1.7.1 +## v1.7.2 ### Added diff --git a/bamboo-specs/build.yaml b/bamboo-specs/build.yaml index 4bd6c8f32..d6900a920 100644 --- a/bamboo-specs/build.yaml +++ b/bamboo-specs/build.yaml @@ -35,7 +35,9 @@ Build: yarn install ${bamboo.varsYarn} yarn build + yarn wiki:build-docs + yarn wiki:build-table rm -rf node_modules - inject-variables: diff --git a/scripts/build-docs.js b/scripts/build-docs.js index 480ed61c3..6ce574322 100644 --- a/scripts/build-docs.js +++ b/scripts/build-docs.js @@ -3,7 +3,12 @@ const path = require('path'); const yaml = require('js-yaml'); const { EOL } = require('os'); -const { getDataFromFiles } = require('./helpers'); +const { + getDataFromFiles, + SCRIPTLET_TYPE, + TRUSTED_SCRIPTLET_TYPE, + REDIRECT_TYPE, +} = require('./helpers'); const { WIKI_DIR_PATH, @@ -12,9 +17,6 @@ const { redirectsFilenames, SCRIPTLETS_SRC_RELATIVE_DIR_PATH, REDIRECTS_SRC_RELATIVE_DIR_PATH, - SCRIPTLET_TYPE, - TRUSTED_SCRIPTLET_TYPE, - REDIRECT_TYPE, } = require('./constants'); const STATIC_REDIRECTS_FILENAME = 'static-redirects.yml'; diff --git a/scripts/check-sources-updates.js b/scripts/check-sources-updates.js index ba6700d20..99fe89408 100644 --- a/scripts/check-sources-updates.js +++ b/scripts/check-sources-updates.js @@ -368,6 +368,6 @@ async function checkForABPRedirectsUpdates() { ${added.length ? `Added: ${added}.` : ''} `; - console.log(message); + throw new Error(message); } }()); diff --git a/scripts/compatibility-table.json b/scripts/compatibility-table.json index a076e15be..3082fabd8 100644 --- a/scripts/compatibility-table.json +++ b/scripts/compatibility-table.json @@ -242,6 +242,9 @@ }, { "ubo": "xml-prune.js" + }, + { + "ubo": "m3u-prune.js" } ], "redirects": [ @@ -448,4 +451,4 @@ "ubo": "noop-0.5s.mp3" } ] -} \ No newline at end of file +} diff --git a/wiki/about-redirects.md b/wiki/about-redirects.md index ac671becb..e446ff986 100644 --- a/wiki/about-redirects.md +++ b/wiki/about-redirects.md @@ -15,6 +15,31 @@ * [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 @@ -155,6 +180,365 @@ Redirects request to an empty VAST 4.0 response. [Redirect source](../src/redirects/static-redirects.yml) * * * +### ⚡️ amazon-apstag + +Mocks Amazon's apstag.js + +Related UBO redirect resource: +https://github.com/gorhill/uBlock/blob/f842ab6d3c1cf0394f95d27092bf59627262da40/src/web_accessible_resources/amazon_apstag.js + +**Example** +``` +||amazon-adsystem.com/aax2/apstag.js$script,redirect=amazon-apstag +``` + +[Redirect source](../src/redirects/amazon-apstag.js) +* * * + +### ⚡️ ati-smarttag + +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 +``` + +[Redirect source](../src/redirects/ati-smarttag.js) +* * * + +### ⚡️ didomi-loader + +Mocks Didomi's CMP loader script. +https://developers.didomi.io/ + +**Example** +``` +||sdk.privacy-center.org/fbf86806f86e/loader.js$script,redirect=didomi-loader +``` + +[Redirect source](../src/redirects/didomi-loader.js) +* * * + +### ⚡️ fingerprintjs2 + +Mocks FingerprintJS v2 +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 +``` + +[Redirect source](../src/redirects/fingerprintjs2.js) +* * * + +### ⚡️ fingerprintjs3 + +Mocks FingerprintJS v3 +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 +``` + +[Redirect source](../src/redirects/fingerprintjs3.js) +* * * + +### ⚡️ gemius + +Mocks Gemius Analytics. +https://flowplayer.com/developers/plugins/gemius + +**Example** +``` +||gapt.hit.gemius.pl/gplayer.js$script,redirect=gemius +``` + +[Redirect source](../src/redirects/gemius.js) +* * * + +### ⚡️ google-analytics-ga + +Mocks old Google Analytics API. + +Related UBO redirect resource: +https://github.com/gorhill/uBlock/blob/a94df7f3b27080ae2dcb3b914ace39c0c294d2f6/src/web_accessible_resources/google-analytics_ga.js + +**Example** +``` +||google-analytics.com/ga.js$script,redirect=google-analytics-ga +``` + +[Redirect source](../src/redirects/google-analytics-ga.js) +* * * + +### ⚡️ google-analytics + +Mocks Google's Analytics and Tag Manager APIs. +[Covers obsolete googletagmanager-gtm redirect functionality](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 + +**Example** +``` +||google-analytics.com/analytics.js$script,redirect=google-analytics +||googletagmanager.com/gtm.js$script,redirect=googletagmanager-gtm +``` + +[Redirect source](../src/redirects/google-analytics.js) +* * * + +### ⚡️ google-ima3 + +Mocks the IMA SDK of Google. + +**Example** +``` +||imasdk.googleapis.com/js/sdkloader/ima3.js$script,redirect=google-ima3 +``` + +[Redirect source](../src/redirects/google-ima3.js) +* * * + +### ⚡️ googlesyndication-adsbygoogle + +Mocks Google AdSense API. + +Related UBO redirect resource: +https://github.com/gorhill/uBlock/blob/a94df7f3b27080ae2dcb3b914ace39c0c294d2f6/src/web_accessible_resources/googlesyndication_adsbygoogle.js + +**Example** +``` +||pagead2.googlesyndication.com/pagead/js/adsbygoogle.js$script,redirect=googlesyndication-adsbygoogle +``` + +[Redirect source](../src/redirects/googlesyndication-adsbygoogle.js) +* * * + +### ⚡️ googletagservices-gpt + +Mocks Google Publisher Tag API. + +Related UBO redirect resource: +https://github.com/gorhill/uBlock/blob/a94df7f3b27080ae2dcb3b914ace39c0c294d2f6/src/web_accessible_resources/googletagservices_gpt.js + +**Example** +``` +||googletagservices.com/tag/js/gpt.js$script,redirect=googletagservices-gpt +``` + +[Redirect source](../src/redirects/googletagservices-gpt.js) +* * * + +### ⚡️ matomo + +Mocks the piwik.js file of Matomo (formerly Piwik). + +**Example** +``` +||example.org/piwik.js$script,redirect=matomo +``` + +[Redirect source](../src/redirects/matomo.js) +* * * + +### ⚡️ metrika-yandex-tag + +Mocks Yandex Metrika API. +https://yandex.ru/support/metrica/objects/method-reference.html + +**Example** +``` +||mc.yandex.ru/metrika/tag.js$script,redirect=metrika-yandex-tag +``` + +[Redirect source](../src/redirects/metrika-yandex-tag.js) +* * * + +### ⚡️ metrika-yandex-watch + +Mocks the old Yandex Metrika API. +https://yandex.ru/support/metrica/objects/_method-reference.html + +**Example** +``` +||mc.yandex.ru/metrika/watch.js$script,redirect=metrika-yandex-watch +``` + +[Redirect source](../src/redirects/metrika-yandex-watch.js) +* * * + +### ⚡️ naver-wcslog + +Mocks wcslog.js of Naver Analytics. + +**Example** +``` +||wcs.naver.net/wcslog.js$script,redirect=naver-wcslog +``` + +[Redirect source](../src/redirects/naver-wcslog.js) +* * * + +### ⚡️ noeval + +Redirects request to the source which sets static properties to PopAds and popns objects. + +Prevents page to use eval. +Notifies about attempts in the console + +Mostly it is used as `scriptlet`. +See [scriptlet description](../wiki/about-scriptlets.md#noeval). + +Related UBO redirect resource: +https://github.com/gorhill/uBlock/wiki/Resources-Library#noeval-silentjs- + +**Example** +``` +||example.org/index.js$script,redirect=noeval +``` + +[Redirect source](../src/redirects/noeval.js) +* * * + +### ⚡️ pardot-1.0 + +Mocks the pd.js file of Salesforce. +https://pi.pardot.com/pd.js +https://developer.salesforce.com/docs/marketing/pardot/overview + +**Example** +``` +||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 + +Sets predefined constants on a page: +- `canRunAds`: `true` +- `isAdBlockActive`: `false` + +**Example** +``` +||playerdrive.me/assets/js/prebid-ads.js$script,redirect=prebid-ads +``` + +[Redirect source](../src/redirects/prebid-ads.js) +* * * + +### ⚡️ prebid + +Mocks the prebid.js header bidding suit. +https://docs.prebid.org/ + +**Example** +``` +||tmgrup.com.tr/bd/hb/prebid.js$script,redirect=prebid +``` + +[Redirect source](../src/redirects/prebid.js) +* * * + +### ⚡️ prevent-bab + +Prevents BlockAdblock script from detecting an ad blocker. + +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 + +**Example** +``` +/blockadblock.$script,redirect=prevent-bab +``` + +[Redirect source](../src/redirects/prevent-bab.js) +* * * + +### ⚡️ prevent-bab2 + +Prevents BlockAdblock script from detecting an ad blocker. + +Related UBO redirect: +https://github.com/gorhill/uBlock/blob/master/src/web_accessible_resources/nobab2.js + +See [redirect description](../wiki/about-redirects.md#prevent-bab2). + +**Syntax** +``` +/blockadblock.$script,redirect=prevent-bab2 +``` + +[Redirect source](../src/redirects/prevent-bab2.js) +* * * + +### ⚡️ prevent-fab-3.2.0 + +Redirects fuckadblock script to the source js file. + +**Example** +``` +\*\/fuckadblock-$script,redirect=prevent-fab-3.2.0 +``` + +[Redirect source](../src/redirects/prevent-fab-3.2.0.js) +* * * + +### ⚡️ prevent-popads-net + +Redirects request to the source which sets static properties to PopAds and popns objects. + +**Example** +``` +||popads.net/pop.js$script,redirect=prevent-popads-net +``` + +[Redirect source](../src/redirects/prevent-popads-net.js) +* * * + +### ⚡️ scorecardresearch-beacon + +Mocks Scorecard Research API. + +Related UBO redirect resource: +https://github.com/gorhill/uBlock/blob/a94df7f3b27080ae2dcb3b914ace39c0c294d2f6/src/web_accessible_resources/scorecardresearch_beacon.js + +**Example** +``` +||sb.scorecardresearch.com/beacon.js$script,redirect=scorecardresearch-beacon +``` + +[Redirect source](../src/redirects/scorecardresearch-beacon.js) +* * * + +### ⚡️ set-popads-dummy + +Redirects request to the source which sets static properties to PopAds and popns objects. + +**Example** +``` +||popads.net^$script,redirect=set-popads-dummy,domain=example.org +``` + +[Redirect source](../src/redirects/set-popads-dummy.js) +* * * + ### ⚡️ click2load.html Redirects resource and replaces supposed content by decoy frame with button for original content recovering diff --git a/wiki/about-scriptlets.md b/wiki/about-scriptlets.md index c8ae24ded..860ce8997 100644 --- a/wiki/about-scriptlets.md +++ b/wiki/about-scriptlets.md @@ -1,2 +1,1768 @@ ## 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) +* [json-prune](#json-prune) +* [log-addEventListener](#log-addEventListener) +* [log-eval](#log-eval) +* [log-on-stack-trace](#log-on-stack-trace) +* [log](#log) +* [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) * * * +### ⚡️ abort-current-inline-script + +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/`. + ``` + 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: + ```html + + ``` + +[Scriptlet source](../src/scriptlets/abort-current-inline-script.js) +* * * + +### ⚡️ abort-on-property-read + +Aborts a script when it attempts to **read** the specified property. + +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 + +**Syntax** +``` +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** +``` +! Aborts script when it tries to access `window.alert` +example.org#%#//scriptlet('abort-on-property-read', 'alert') + +! Aborts script when it tries to access `navigator.language` +example.org#%#//scriptlet('abort-on-property-read', 'navigator.language') +``` + +[Scriptlet source](../src/scriptlets/abort-on-property-read.js) +* * * + +### ⚡️ abort-on-property-write + +Aborts a script when it attempts to **write** the specified property. + +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 + +**Syntax** +``` +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` + +**Examples** +``` +! 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 + +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** +``` +example.com#%#//scriptlet('abort-on-stack-trace', property, stack) +``` + +- `property` - required, path to a property. The property must be attached to window. +- `stack` - required, string that must match the current function call stack trace. + - values to abort inline or injected script, accordingly: + - `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') + +! 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') + +! 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') + +! Aborts script when it tries to access `window.Ya` and it's an inline script +example.org#%#//scriptlet('abort-on-stack-trace', 'Ya', 'inlineScript') + +! Aborts script when it tries to access `window.Ya` and it's an injected script +example.org#%#//scriptlet('abort-on-stack-trace', 'Ya', 'injectedScript') +``` + +[Scriptlet source](../src/scriptlets/abort-on-stack-trace.js) +* * * + +### ⚡️ adjust-setInterval + +Adjusts delay for specified setInterval() callbacks. + +Related UBO scriptlet: +https://github.com/gorhill/uBlock/wiki/Resources-Library#nano-setinterval-boosterjs- + +**Syntax** +``` +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 +- `matchDelay` - optional, defaults to 1000, matching setInterval delay; decimal integer OR '*' for any delay +- `boost` - optional, default to 0.05, float, capped at 50 times for up and down (0.02...50), setInterval delay multiplier + +**Examples** +1. Adjust all setInterval() x20 times where delay equal 1000ms: + ``` + example.org#%#//scriptlet('adjust-setInterval') + ``` + +2. Adjust all setInterval() x20 times where callback matched with `example` and delay equal 1000ms + ``` + example.org#%#//scriptlet('adjust-setInterval', 'example') + ``` + +3. Adjust all setInterval() x20 times where callback matched with `example` and delay equal 400ms + ``` + example.org#%#//scriptlet('adjust-setInterval', 'example', '400') + ``` + +4. Slow down setInterval() x2 times where callback matched with `example` and delay equal 1000ms + ``` + example.org#%#//scriptlet('adjust-setInterval', 'example', '', '2') + ``` +5. Adjust all setInterval() x50 times where delay equal 2000ms + ``` + example.org#%#//scriptlet('adjust-setInterval', '', '2000', '0.02') + ``` +6. Adjust all setInterval() x50 times where delay is randomized + ``` + example.org#%#//scriptlet('adjust-setInterval', '', '*', '0.02') + ``` + +[Scriptlet source](../src/scriptlets/adjust-setInterval.js) +* * * + +### ⚡️ adjust-setTimeout + +Adjusts delay for specified setTimeout() callbacks. + +Related UBO scriptlet: +https://github.com/gorhill/uBlock/wiki/Resources-Library#nano-settimeout-boosterjs- + +**Syntax** +``` +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 +- `matchDelay` - optional, defaults to 1000, matching setTimeout delay; decimal integer OR '*' for any delay +- `boost` - optional, default to 0.05, float, capped at 50 times for up and down (0.02...50), setTimeout delay multiplier + +**Examples** +1. Adjust all setTimeout() x20 times where timeout equal 1000ms: + ``` + example.org#%#//scriptlet('adjust-setTimeout') + ``` + +2. Adjust all setTimeout() x20 times where callback matched with `example` and timeout equal 1000ms + ``` + example.org#%#//scriptlet('adjust-setTimeout', 'example') + ``` + +3. Adjust all setTimeout() x20 times where callback matched with `example` and timeout equal 400ms + ``` + example.org#%#//scriptlet('adjust-setTimeout', 'example', '400') + ``` + +4. Slow down setTimeout() x2 times where callback matched with `example` and timeout equal 1000ms + ``` + example.org#%#//scriptlet('adjust-setTimeout', 'example', '', '2') + ``` +5. Adjust all setTimeout() x50 times where timeout equal 2000ms + ``` + example.org#%#//scriptlet('adjust-setTimeout', '', '2000', '0.02') + ``` +6. Adjust all setTimeout() x20 times where callback matched with `test` and timeout is randomized + ``` + example.org#%#//scriptlet('adjust-setTimeout', 'test', '*') + ``` + +[Scriptlet source](../src/scriptlets/adjust-setTimeout.js) +* * * + +### ⚡️ close-window + +Closes the browser tab immediately. + +> `window.close()` usage is restricted in Chrome. In this case +tab will only be closed if using AdGuard browser extension. + +**Syntax** +``` +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. + +**Examples** +``` +! closes any example.org tab +example.org#%#//scriptlet('close-window') + +! closes specific example.org tab +example.org#%#//scriptlet('close-window', '/example-page.html') +``` + +[Scriptlet source](../src/scriptlets/close-window.js) +* * * + +### ⚡️ 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. + +**It is not supposed to be used in production filter lists!** + +**Syntax** +``` +! 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 + +This scriptlet is basically the same as [abort-on-property-read](#abort-on-property-read), but instead of aborting it starts the debugger. + +**It is not supposed to be used in production filter lists!** + +**Syntax** +``` +! Debug script if it tries to access `window.alert` +example.org#%#//scriptlet('debug-on-property-read', 'alert') +! of `window.open` +example.org#%#//scriptlet('debug-on-property-read', 'open') +``` + +[Scriptlet source](../src/scriptlets/debug-on-property-read.js) +* * * + +### ⚡️ 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. + +**It is not supposed to be used in production filter lists!** + +**Syntax** +``` +! 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 + +Wraps the `console.dir` API to call the `toString` method of the argument. +There are several adblock circumvention systems that detect browser devtools +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** +``` +example.org#%#//scriptlet('dir-string'[, times]) +``` +- `times` - optional, the number of times to call the `toString` method of the argument to `console.dir` + +**Example** +``` +! Run 2 times +example.org#%#//scriptlet('dir-string', '2') +``` + +[Scriptlet source](../src/scriptlets/dir-string.js) +* * * + +### ⚡️ disable-newtab-links + +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** +``` +example.org#%#//scriptlet('disable-newtab-links') +``` + +[Scriptlet source](../src/scriptlets/disable-newtab-links.js) +* * * + +### ⚡️ hide-in-shadow-dom + +Hides elements inside open shadow DOM elements. + +**Syntax** +``` +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 + +> `baseSelector` should match element of the page DOM, but not of shadow DOM + +**Examples** +``` +! hides menu bar +virustotal.com#%#//scriptlet('hide-in-shadow-dom', 'iron-pages', 'vt-virustotal-app') + +! hides floating element +virustotal.com#%#//scriptlet('hide-in-shadow-dom', 'vt-ui-contact-fab') +``` + +[Scriptlet source](../src/scriptlets/hide-in-shadow-dom.js) +* * * + +### ⚡️ json-prune + +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 + +**Syntax** +``` +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 +- `stack` - optional, string or regular expression that must match the current function call stack trace; +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 ...' + +**Examples** +1. Removes property `example` from the results of JSON.parse call + ``` + example.org#%#//scriptlet('json-prune', 'example') + ``` + + For instance, the following call will return `{ one: 1}` + + ```html + JSON.parse('{"one":1,"example":true}') + ``` + +2. If there are no specified properties in the result of JSON.parse call, pruning will NOT occur + ``` + example.org#%#//scriptlet('json-prune', 'one', 'obligatoryProp') + ``` + + For instance, the following call will return `{ one: 1, two: 2}` + + ```html + JSON.parse('{"one":1,"two":2}') + ``` + +3. A property in a list of properties can be a chain of properties + + ``` + example.org#%#//scriptlet('json-prune', 'a.b', 'adpath.url.first') + ``` + +4. Removes property `content.ad` from the results of JSON.parse call if its error stack trace contains `test.js` + ``` + 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 + + ``` + example.org#%#//scriptlet('json-prune', 'content.*.media.src', 'content.*.media.preroll') + ``` + +6. Call with no arguments will log the current hostname and json payload at the console + ``` + example.org#%#//scriptlet('json-prune') + ``` + +7. Call with only second argument will log the current hostname and matched json payload at the console + ``` + example.org#%#//scriptlet('json-prune', '', '"id":"117458"') + ``` + +[Scriptlet source](../src/scriptlets/json-prune.js) +* * * + +### ⚡️ log-addEventListener + +Logs all addEventListener calls to the console. + +Related UBO scriptlet: +https://github.com/gorhill/uBlock/wiki/Resources-Library#addeventlistener-loggerjs- + +**Syntax** +``` +example.org#%#//scriptlet('log-addEventListener') +``` + +[Scriptlet source](../src/scriptlets/log-addEventListener.js) +* * * + +### ⚡️ log-eval + +Logs all `eval()` or `new Function()` calls to the console. + +**Syntax** +``` +example.org#%#//scriptlet('log-eval') +``` + +[Scriptlet source](../src/scriptlets/log-eval.js) +* * * + +### ⚡️ log-on-stack-trace + +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** +``` +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 + +A simple scriptlet which only purpose is to print arguments to console. +This scriptlet can be helpful for debugging and troubleshooting other scriptlets. + +**Example** +``` +example.org#%#//scriptlet('log', 'arg1', 'arg2') +``` + +[Scriptlet source](../src/scriptlets/log.js) +* * * + +### ⚡️ no-topics + +Prevents using The Topics API +https://developer.chrome.com/docs/privacy-sandbox/topics/ + +**Syntax** +``` +example.org#%#//scriptlet('no-topics') +``` + +[Scriptlet source](../src/scriptlets/no-topics.js) +* * * + +### ⚡️ noeval + +Prevents page to use eval. +Notifies about attempts in the console + +Related UBO scriptlet: +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** +``` +example.org#%#//scriptlet('noeval') +``` + +[Scriptlet source](../src/scriptlets/noeval.js) +* * * + +### ⚡️ nowebrtc + +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** +``` +example.org#%#//scriptlet('nowebrtc') +``` + +[Scriptlet source](../src/scriptlets/nowebrtc.js) +* * * + +### ⚡️ prevent-addEventListener + +Prevents adding event listeners for the specified events and callbacks. + +Related UBO scriptlet: +https://github.com/gorhill/uBlock/wiki/Resources-Library#addeventlistener-defuserjs- + +**Syntax** +``` +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 +- `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 + +**Examples** +1. Prevent all `click` listeners: +``` + example.org#%#//scriptlet('prevent-addEventListener', 'click') +``` + +2. Prevent 'click' listeners with the callback body containing `searchString`. +``` + example.org#%#//scriptlet('prevent-addEventListener', 'click', 'searchString') +``` + + For instance, this listener will not be called: +```javascript + el.addEventListener('click', () => { + window.test = 'searchString'; + }); +``` + +[Scriptlet source](../src/scriptlets/prevent-addEventListener.js) +* * * + +### ⚡️ prevent-adfly + +Prevents anti-adblock scripts on adfly short links. + +Related UBO scriptlet: +https://github.com/gorhill/uBlock/wiki/Resources-Library#adfly-defuserjs- + +**Syntax** +``` +example.org#%#//scriptlet('prevent-adfly') +``` + +[Scriptlet source](../src/scriptlets/prevent-adfly.js) +* * * + +### ⚡️ prevent-bab + +Prevents BlockAdblock script from detecting an ad blocker. + +Related UBO scriptlet: +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** +``` +example.org#%#//scriptlet('prevent-bab') +``` + +[Scriptlet source](../src/scriptlets/prevent-bab.js) +* * * + +### ⚡️ prevent-element-src-loading + +Prevents target element source loading without triggering 'onerror' listeners and not breaking 'onload' ones. + +**Syntax** +``` +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: + - `script` + - `img` + - `iframe` +- `match` - required, string or regular expression for matching the element's URL; + +**Examples** +1. Prevent script source loading: +``` + example.org#%#//scriptlet('prevent-element-src-loading', 'script' ,'adsbygoogle') +``` + +[Scriptlet source](../src/scriptlets/prevent-element-src-loading.js) +* * * + +### ⚡️ prevent-eval-if + +Prevents page to use eval matching payload. + +Related UBO scriptlet: +https://github.com/gorhill/uBlock/wiki/Resources-Library#noeval-ifjs- + +**Syntax** +``` +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 + +**Examples** +``` +! 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 + +Prevents execution of the FAB script v3.2.0. + +Related UBO scriptlet: +https://github.com/gorhill/uBlock/wiki/Resources-Library#fuckadblockjs-320- + +**Syntax** +``` +example.org#%#//scriptlet('prevent-fab-3.2.0') +``` + +[Scriptlet source](../src/scriptlets/prevent-fab-3.2.0.js) +* * * + +### ⚡️ prevent-fetch + +Prevents `fetch` calls if **all** given parameters match + +Related UBO scriptlet: +https://github.com/gorhill/uBlock/wiki/Resources-Library#no-fetch-ifjs- + +**Syntax** +``` +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 + +> Usage with no arguments will log fetch calls to browser console; +which is useful for debugging but not permitted for production filter lists. + +**Examples** +1. Log all fetch calls + ``` + example.org#%#//scriptlet('prevent-fetch') + ``` + +2. Prevent all fetch calls + ``` + example.org#%#//scriptlet('prevent-fetch', '*') + OR + example.org#%#//scriptlet('prevent-fetch', '') + ``` + +3. Prevent fetch call for specific url + ``` + example.org#%#//scriptlet('prevent-fetch', '/url\\.part/') + ``` + +4. Prevent fetch call for specific request method + ``` + example.org#%#//scriptlet('prevent-fetch', 'method:HEAD') + ``` + +5. Prevent fetch call for specific url and request method + ``` + example.org#%#//scriptlet('prevent-fetch', '/specified_url_part/ method:/HEAD|GET/') + ``` + +6. Prevent fetch call and specify response body value + ``` + ! Specify response body for fetch call to a specific url + example.org#%#//scriptlet('prevent-fetch', '/specified_url_part/ method:/HEAD|GET/', 'emptyArr') + + ! Specify response body for all fetch calls + example.org#%#//scriptlet('prevent-fetch', '', 'emptyArr') + ``` + +[Scriptlet source](../src/scriptlets/prevent-fetch.js) +* * * + +### ⚡️ prevent-popads-net + +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** +``` +example.org#%#//scriptlet('prevent-popads-net') +``` + +[Scriptlet source](../src/scriptlets/prevent-popads-net.js) +* * * + +### ⚡️ prevent-refresh + +Prevents reloading of a document through a meta "refresh" tag. + +Related UBO scriptlet: +https://github.com/gorhill/uBlock/wiki/Resources-Library#refresh-defuserjs- + +**Syntax** +``` +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. + +**Examples** +1. Prevent reloading of a document through a meta "refresh" tag. +``` + enrt.eu#%#//scriptlet('prevent-refresh') +``` + +2. Prevent reloading of a document with delay. +``` + cryptodirectories.com#%#//scriptlet('prevent-refresh', 3) +``` + +[Scriptlet source](../src/scriptlets/prevent-refresh.js) +* * * + +### ⚡️ prevent-requestAnimationFrame + +Prevents a `requestAnimationFrame` call +if the text of the callback is matching the specified search string which does not start with `!`; +otherwise mismatched calls should be defused. + +Related UBO scriptlet: +https://github.com/gorhill/uBlock/wiki/Resources-Library#no-requestanimationframe-ifjs- + +**Syntax** +``` +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. + +Call with no argument will log all requestAnimationFrame calls while debugging. +So do not use the scriptlet without any parameter in production filter lists. + +**Examples** +1. Prevents `requestAnimationFrame` calls if the callback matches `/\.test/`. + ```bash + example.org#%#//scriptlet('prevent-requestAnimationFrame', '/\.test/') + ``` + + For instance, the following call will be prevented: + ```javascript + var times = 0; + requestAnimationFrame(function change() { + window.test = 'new value'; + if (times < 2) { + times += 1; + requestAnimationFrame(change); + } + }); + ``` +2. Prevents `requestAnimationFrame` calls if **does not match** 'check'. + ```bash + example.org#%#//scriptlet('prevent-requestAnimationFrame', '!check') + ``` + + For instance, only the first call will be prevented: + + ```javascript + var timesFirst = 0; + requestAnimationFrame(function changeFirst() { + window.check = 'should not be prevented'; + if (timesFirst < 2) { + timesFirst += 1; + requestAnimationFrame(changeFirst); + } + }); + + var timesSecond = 0; + requestAnimationFrame(function changeSecond() { + window.second = 'should be prevented'; + if (timesSecond < 2) { + timesSecond += 1; + requestAnimationFrame(changeSecond); + } + }); + ``` + +[Scriptlet source](../src/scriptlets/prevent-requestAnimationFrame.js) +* * * + +### ⚡️ prevent-setInterval + +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. + +Related UBO scriptlet: +https://github.com/gorhill/uBlock/wiki/Resources-Library#no-setinterval-ifjs- + +**Syntax** +``` +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`. +- `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. + +> 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`. + + **Examples** +1. Prevents `setInterval` calls if the callback matches `/\.test/` regardless of the delay. + ```bash + 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`. + ``` + 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"; + }, 300); + setInterval(function () { + window.test = "value -- executed"; + }, 400); + setInterval(function () { + window.value = "test -- executed"; + }, 500); + ``` + +3. Prevents `setInterval` calls if the callback contains `value` and the delay is not set to `300`. + ``` + 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"; + }, 300); + setInterval(function () { + window.test = "value 2 -- prevented"; + }, 400); + setInterval(function () { + window.test = "value 3 -- prevented"; + }, 500); + ``` + +4. Prevents `setInterval` calls if the callback does not contain `value` and the delay is not set to `300`. + ``` + 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"; + }, 300); + setInterval(function () { + window.test = "test -- prevented"; + }, 400); + setInterval(function () { + window.test = "value -- executed"; + }, 400); + setInterval(function () { + window.value = "test -- executed"; + }, 500); + ``` + +[Scriptlet source](../src/scriptlets/prevent-setInterval.js) +* * * + +### ⚡️ prevent-setTimeout + +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. + +Related UBO scriptlet: +https://github.com/gorhill/uBlock/wiki/Resources-Library#no-settimeout-ifjs- + +**Syntax** +``` +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`. +- `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. + +> 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`. + +**Examples** +1. Prevents `setTimeout` calls if the callback matches `/\.test/` regardless of the delay. + ```bash + 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`. + ``` + 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"; + }, 300); + setTimeout(function () { + window.test = "value -- executed"; + }, 400); + setTimeout(function () { + window.value = "test -- executed"; + }, 500); + ``` + +3. Prevents `setTimeout` calls if the callback contains `value` and the delay is not set to `300`. + ``` + 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"; + }, 300); + setTimeout(function () { + window.test = "value 2 -- prevented"; + }, 400); + setTimeout(function () { + window.test = "value 3 -- prevented"; + }, 500); + ``` + +4. Prevents `setTimeout` calls if the callback does not contain `value` and the delay is not set to `300`. + ``` + 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"; + }, 300); + setTimeout(function () { + window.test = "test -- prevented"; + }, 400); + setTimeout(function () { + window.test = "value -- executed"; + }, 400); + setTimeout(function () { + window.value = "test -- executed"; + }, 500); + ``` + +[Scriptlet source](../src/scriptlets/prevent-setTimeout.js) +* * * + +### ⚡️ 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. + +Related UBO scriptlet: +https://github.com/gorhill/uBlock/wiki/Resources-Library#windowopen-defuserjs- + +**Syntax** +``` +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. +- `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. +- `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. + +**Examples** +1. Prevent all `window.open` calls: +``` + example.org#%#//scriptlet('prevent-window-open') +``` + +2. Prevent `window.open` for all URLs containing `example`: +``` + example.org#%#//scriptlet('prevent-window-open', 'example') +``` + +3. Prevent `window.open` for all URLs matching RegExp `/example\./`: +``` + example.org#%#//scriptlet('prevent-window-open', '/example\./') +``` + +4. Prevent `window.open` for all URLs **NOT** containing `example`: +``` + 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}') +``` + +> For better compatibility with uBO, old syntax is not recommended to use. + +[Scriptlet source](../src/scriptlets/prevent-window-open.js) +* * * + +### ⚡️ prevent-xhr + +Prevents `xhr` calls if **all** given parameters match. + +Related UBO scriptlet: +https://github.com/gorhill/uBlock/wiki/Resources-Library#no-xhr-ifjs- + +**Syntax** +``` +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 `.open()` call; empty string or wildcard * for all `.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 `.open()` call +- randomize - defaults to `false` for empty responseText, optional argument to randomize responseText of matched XMLHttpRequest's response; possible values: + - boolean 'true' to randomize responseText, random alphanumeric string of 10 symbols + - string value to customize responseText data, colon-separated pairs name:value 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. + +**Examples** +1. Log all XMLHttpRequests + ``` + example.org#%#//scriptlet('prevent-xhr') + ``` + +2. Prevent all XMLHttpRequests + ``` + example.org#%#//scriptlet('prevent-xhr', '*') + example.org#%#//scriptlet('prevent-xhr', '') + ``` + +3. Prevent XMLHttpRequests for specific url + ``` + example.org#%#//scriptlet('prevent-xhr', 'example.org') + ``` + +4. Prevent XMLHttpRequests for specific request method + ``` + example.org#%#//scriptlet('prevent-xhr', 'method:HEAD') + ``` + +5. Prevent XMLHttpRequests for specific url and specified request methods + ``` + example.org#%#//scriptlet('prevent-xhr', 'example.org method:/HEAD|GET/') + ``` + +6. Prevent XMLHttpRequests for specific url and randomize it's response text + ``` + example.org#%#//scriptlet('prevent-xhr', 'example.org', 'true') + ``` + +7. Prevent XMLHttpRequests for specific url and randomize it's response text with range + ``` + example.org#%#//scriptlet('prevent-xhr', 'example.org', 'length:100-300') + ``` + +[Scriptlet source](../src/scriptlets/prevent-xhr.js) +* * * + +### ⚡️ remove-attr + +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, +or as specified by applying argument. + +Related UBO scriptlet: +https://github.com/gorhill/uBlock/wiki/Resources-Library#remove-attrjs- + +**Syntax** +``` +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: + - `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 + ``` + example.org#%#//scriptlet('remove-attr', 'example|test') + ``` + + ```html + +