diff --git a/scripts/build-docs.js b/scripts/build-docs.js index c785c8589..3f33fc341 100644 --- a/scripts/build-docs.js +++ b/scripts/build-docs.js @@ -105,11 +105,13 @@ const getMarkdownData = (dataItems) => { description, source, }) => { - acc.list.push(`* [${name}](#${name})${EOL}`); + // low case name should be used as anchor + acc.list.push(`* [${name}](#${name.toLowerCase()})${EOL}`); - const typeOfSrc = type === 'scriptlet' ? 'Scriptlet' : 'Redirect'; + const typeOfSrc = type.toLowerCase().includes('scriptlet') ? 'Scriptlet' : 'Redirect'; - const body = `### ⚡️ ${name} + // low case name should be used as anchor + const body = `### ⚡️ ${name} ${description}${EOL} [${typeOfSrc} source](${source}) * * *${EOL}${EOL}`; diff --git a/scripts/compatibility-table.json b/scripts/compatibility-table.json index 0172bf512..9eb792233 100644 --- a/scripts/compatibility-table.json +++ b/scripts/compatibility-table.json @@ -106,6 +106,10 @@ { "adg": "prevent-popads-net" }, + { + "adg": "prevent-refresh", + "ubo": "refresh-defuser.js" + }, { "adg": "prevent-requestAnimationFrame", "ubo": "no-requestAnimationFrame-if.js (norafif.js)" @@ -144,6 +148,10 @@ { "adg": "set-popads-dummy" }, + { + "adg": "xml-prune", + "ubo": "xml-prune.js" + }, { "ubo": "webrtc-if.js" }, @@ -231,18 +239,12 @@ { "ubo": "abort-current-script.js (acs.js, abort-current-inline-script.js, acis.js)" }, - { - "ubo": "refresh-defuser.js" - }, { "ubo": "no-floc.js" }, { "ubo": "window.name-defuser.js" }, - { - "ubo": "xml-prune.js" - }, { "ubo": "m3u-prune.js" } diff --git a/src/scriptlets/prevent-addEventListener.js b/src/scriptlets/prevent-addEventListener.js index 65410c868..c30ee3721 100644 --- a/src/scriptlets/prevent-addEventListener.js +++ b/src/scriptlets/prevent-addEventListener.js @@ -27,21 +27,22 @@ import { * * **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 + * + * ```javascript * el.addEventListener('click', () => { * window.test = 'searchString'; * }); - * ``` + * ``` */ /* eslint-enable max-len */ export function preventAddEventListener(source, typeSearch, listenerSearch) { diff --git a/src/scriptlets/prevent-window-open.js b/src/scriptlets/prevent-window-open.js index c5e5b0252..1c303c8b9 100644 --- a/src/scriptlets/prevent-window-open.js +++ b/src/scriptlets/prevent-window-open.js @@ -47,36 +47,36 @@ import { * * **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') - * ``` - * + * ``` + *P * 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. */ diff --git a/src/scriptlets/remove-cookie.js b/src/scriptlets/remove-cookie.js index 0d1897973..871a9da15 100644 --- a/src/scriptlets/remove-cookie.js +++ b/src/scriptlets/remove-cookie.js @@ -18,16 +18,17 @@ import { hit, toRegExp } from '../helpers/index'; * * **Examples** * 1. Removes all cookies: - * ``` + * ``` * example.org#%#//scriptlet('remove-cookie') - * ``` + * ``` * - * 2. Removes cookies which name contains `example` string. - * ``` + * 2. Removes cookies which name contains `example` string: + * ``` * example.org#%#//scriptlet('remove-cookie', 'example') - * ``` + * ``` + * + * For instance this cookie will be removed: * - * For instance this cookie will be removed * ```javascript * document.cookie = '__example=randomValue'; * ``` diff --git a/src/scriptlets/trusted-click-element.js b/src/scriptlets/trusted-click-element.js index d79e13016..1eb7a4354 100644 --- a/src/scriptlets/trusted-click-element.js +++ b/src/scriptlets/trusted-click-element.js @@ -24,6 +24,7 @@ import { * - `cookie` - test string or regex against cookies on a page * - `localStorage` - check if localStorage item is present * - 'delay' - optional, time in ms to delay scriptlet execution, defaults to instant execution. + * * **Examples** * 1. Click single element by selector * ``` diff --git a/wiki/about-scriptlets.md b/wiki/about-scriptlets.md index a69de64d3..e9197175f 100644 --- a/wiki/about-scriptlets.md +++ b/wiki/about-scriptlets.md @@ -3,8 +3,8 @@ * [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) +* [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) @@ -13,14 +13,14 @@ * [disable-newtab-links](#disable-newtab-links) * [hide-in-shadow-dom](#hide-in-shadow-dom) * [json-prune](#json-prune) -* [log-addEventListener](#log-addEventListener) +* [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-addEventListener](#prevent-addeventlistener) * [prevent-adfly](#prevent-adfly) * [prevent-bab](#prevent-bab) * [prevent-element-src-loading](#prevent-element-src-loading) @@ -29,9 +29,9 @@ * [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-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) @@ -205,7 +205,7 @@ example.org#%#//scriptlet('abort-on-stack-trace', 'Ya', 'injectedScript') [Scriptlet source](../src/scriptlets/abort-on-stack-trace.js) * * * -### ⚡️ adjust-setInterval +### ⚡️ adjust-setInterval Adjusts delay for specified setInterval() callbacks. @@ -254,7 +254,7 @@ defaults to match all callbacks; invalid regular expression will cause exit and [Scriptlet source](../src/scriptlets/adjust-setInterval.js) * * * -### ⚡️ adjust-setTimeout +### ⚡️ adjust-setTimeout Adjusts delay for specified setTimeout() callbacks. @@ -523,7 +523,7 @@ e.g. 'ad.*.src' instead of 'ad.0.src ad.1.src ad.2.src ...' [Scriptlet source](../src/scriptlets/json-prune.js) * * * -### ⚡️ log-addEventListener +### ⚡️ log-addEventListener Logs all addEventListener calls to the console. @@ -627,7 +627,7 @@ example.org#%#//scriptlet('nowebrtc') [Scriptlet source](../src/scriptlets/nowebrtc.js) * * * -### ⚡️ prevent-addEventListener +### ⚡️ prevent-addEventListener Prevents adding event listeners for the specified events and callbacks. @@ -646,21 +646,22 @@ defaults to match all listeners; invalid regular expression will cause exit and **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 + + ```javascript el.addEventListener('click', () => { window.test = 'searchString'; }); -``` + ``` [Scriptlet source](../src/scriptlets/prevent-addEventListener.js) * * * @@ -877,7 +878,7 @@ example.org#%#//scriptlet('prevent-refresh'[, delay]) [Scriptlet source](../src/scriptlets/prevent-refresh.js) * * * -### ⚡️ prevent-requestAnimationFrame +### ⚡️ prevent-requestAnimationFrame Prevents a `requestAnimationFrame` call if the text of the callback is matching the specified search string which does not start with `!`; @@ -945,7 +946,7 @@ So do not use the scriptlet without any parameter in production filter lists. [Scriptlet source](../src/scriptlets/prevent-requestAnimationFrame.js) * * * -### ⚡️ prevent-setInterval +### ⚡️ 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 `!`; @@ -1047,7 +1048,7 @@ and obviously it can not be matched by `matchCallback`. [Scriptlet source](../src/scriptlets/prevent-setInterval.js) * * * -### ⚡️ prevent-setTimeout +### ⚡️ 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 `!`; @@ -1174,36 +1175,36 @@ for accessing its methods (blur(), focus() etc.) and will be removed after the d **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') -``` - + ``` +P 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. @@ -1416,16 +1417,17 @@ example.org#%#//scriptlet('remove-cookie'[, match]) **Examples** 1. Removes all cookies: -``` + ``` example.org#%#//scriptlet('remove-cookie') -``` + ``` -2. Removes cookies which name contains `example` string. -``` +2. Removes cookies which name contains `example` string: + ``` example.org#%#//scriptlet('remove-cookie', 'example') -``` + ``` + + For instance this cookie will be removed: - For instance this cookie will be removed ```javascript document.cookie = '__example=randomValue'; ``` diff --git a/wiki/about-trusted-scriptlets.md b/wiki/about-trusted-scriptlets.md index 6747fc54a..0e36a5091 100644 --- a/wiki/about-trusted-scriptlets.md +++ b/wiki/about-trusted-scriptlets.md @@ -22,6 +22,7 @@ Multiple conditions are allowed inside one `extraMatch` but they should be delim - `cookie` - test string or regex against cookies on a page - `localStorage` - check if localStorage item is present - 'delay' - optional, time in ms to delay scriptlet execution, defaults to instant execution. + **Examples** 1. Click single element by selector ``` @@ -58,7 +59,7 @@ example.com#%#//scriptlet('trusted-click-element', 'button[name="agree"]', 'loca example.com#%#//scriptlet('trusted-click-element', 'button[name="agree"], input[type="submit"][value="akkoord"]', 'cookie:cmpconsent, localStorage:promo', '250') ``` -[Redirect source](../src/scriptlets/trusted-click-element.js) +[Scriptlet source](../src/scriptlets/trusted-click-element.js) * * * ### ⚡️ trusted-replace-fetch-response @@ -114,7 +115,7 @@ which is useful for debugging but only allowed for production filter lists. example.org#%#//scriptlet('trusted-replace-fetch-response', '*', '', 'example.com') ``` -[Redirect source](../src/scriptlets/trusted-replace-fetch-response.js) +[Scriptlet source](../src/scriptlets/trusted-replace-fetch-response.js) * * * ### ⚡️ trusted-replace-xhr-response @@ -167,7 +168,7 @@ which is useful for debugging but not permitted for production filter lists. example.org#%#//scriptlet('trusted-replace-xhr-response', '*', '', 'example.com') ``` -[Redirect source](../src/scriptlets/trusted-replace-xhr-response.js) +[Scriptlet source](../src/scriptlets/trusted-replace-xhr-response.js) * * * ### ⚡️ trusted-set-cookie-reload @@ -223,7 +224,7 @@ example.org#%#//scriptlet('trusted-set-cookie-reload', 'cmpconsent', 'accept', ' example.org#%#//scriptlet('trusted-set-cookie-reload', 'cmpconsent', 'decline', '', 'none') ``` -[Redirect source](../src/scriptlets/trusted-set-cookie-reload.js) +[Scriptlet source](../src/scriptlets/trusted-set-cookie-reload.js) * * * ### ⚡️ trusted-set-cookie @@ -278,7 +279,7 @@ example.org#%#//scriptlet('trusted-set-cookie', 'cmpconsent', 'accept', '1year') example.org#%#//scriptlet('trusted-set-cookie', 'cmpconsent', 'decline', '', 'none') ``` -[Redirect source](../src/scriptlets/trusted-set-cookie.js) +[Scriptlet source](../src/scriptlets/trusted-set-cookie.js) * * * ### ⚡️ trusted-set-local-storage-item @@ -324,6 +325,6 @@ example.org#%#//scriptlet('trusted-set-local-storage-item', 'player.live.current example.org#%#//scriptlet('trusted-set-local-storage-item', 'ppu_main_none', '') ``` -[Redirect source](../src/scriptlets/trusted-set-local-storage-item.js) +[Scriptlet source](../src/scriptlets/trusted-set-local-storage-item.js) * * * diff --git a/wiki/compatibility-table.md b/wiki/compatibility-table.md index bbdc5dfa1..70d7b92c0 100644 --- a/wiki/compatibility-table.md +++ b/wiki/compatibility-table.md @@ -30,6 +30,7 @@ | [prevent-fetch](../wiki/about-scriptlets.md#prevent-fetch) | no-fetch-if.js | | | [prevent-xhr](../wiki/about-scriptlets.md#prevent-xhr) | no-xhr-if.js | | | [prevent-popads-net](../wiki/about-scriptlets.md#prevent-popads-net) | | | +| [prevent-refresh](../wiki/about-scriptlets.md#prevent-refresh) | refresh-defuser.js | | | [prevent-requestAnimationFrame](../wiki/about-scriptlets.md#prevent-requestAnimationFrame) | no-requestAnimationFrame-if.js (norafif.js) | | | [prevent-setInterval](../wiki/about-scriptlets.md#prevent-setInterval) | no-setInterval-if.js (nosiif.js) | | | [prevent-setTimeout](../wiki/about-scriptlets.md#prevent-setTimeout) | no-setTimeout-if.js (nostif.js, setTimeout-defuser.js) | | @@ -40,6 +41,7 @@ | [set-attr](../wiki/about-scriptlets.md#set-attr) | | | | [set-constant](../wiki/about-scriptlets.md#set-constant) | set-constant.js (set.js) | override-property-read | | [set-popads-dummy](../wiki/about-scriptlets.md#set-popads-dummy) | | | +| [xml-prune](../wiki/about-scriptlets.md#xml-prune) | xml-prune.js | | | | webrtc-if.js | | | | overlay-buster.js | | | | alert-buster.js | | @@ -69,10 +71,8 @@ | | | abort-on-iframe-property-read | | | | abort-on-iframe-property-write | | | abort-current-script.js (acs.js, abort-current-inline-script.js, acis.js) | | -| | refresh-defuser.js | | | | no-floc.js | | | | window.name-defuser.js | | -| | xml-prune.js | | | | m3u-prune.js | |