From a31a4f10991c0ecfda988674dabe2a21251c2192 Mon Sep 17 00:00:00 2001 From: Stanislav Atroschenko Date: Fri, 30 Dec 2022 15:01:38 +0300 Subject: [PATCH 1/6] fix compatibility table for prevent refresh Merge in ADGUARD-FILTERS/scriptlets from fix/compatibility-table_prevent-refresh to master Squashed commit of the following: commit 550a199c075b4b253c11635439a2b668f7a4399f Author: Stanislav A Date: Fri Dec 30 13:20:31 2022 +0300 add xml-prune to table commit 7582335d17d2bb6f04e252e7738dad19cd00235f Author: Stanislav A Date: Fri Dec 30 13:03:13 2022 +0300 move refresh higher commit 0ac5a3ae275315759c98a0b79ee9c342008a983f Author: Stanislav A Date: Fri Dec 30 12:59:13 2022 +0300 fix compatibility table for prevent refresh --- scripts/compatibility-table.json | 14 ++++++++------ wiki/compatibility-table.md | 4 ++-- 2 files changed, 10 insertions(+), 8 deletions(-) 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/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 | | From 9f307ecc75d2406f29baabbc5a0aa21a8aaffe24 Mon Sep 17 00:00:00 2001 From: Atlassian Bamboo Date: Fri, 30 Dec 2022 15:02:00 +0300 Subject: [PATCH 2/6] skipci: Automatic increment build number --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b49d12a89..c8957f133 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@adguard/scriptlets", - "version": "1.7.20", + "version": "1.7.21", "description": "AdGuard's JavaScript library of Scriptlets and Redirect resources", "scripts": { "build": "babel-node bundler.js", From 1c541ee9abefd359aa3eb08134d73f2b60d095fc Mon Sep 17 00:00:00 2001 From: Stanislav Atroschenko Date: Tue, 10 Jan 2023 15:07:00 +0300 Subject: [PATCH 3/6] AG-18732 fix errors in scriptlets wiki Merge in ADGUARD-FILTERS/scriptlets from fix/AG-18732 to master Squashed commit of the following: commit bc20d83ad54d69c93039939eb87a304f4ddf5007 Author: Stanislav A Date: Tue Jan 10 14:26:58 2023 +0300 fix 'Redirect source' links for trusted scriptlets commit bf5af430e416941c68bbe2a2d39377ca495de4f9 Author: Stanislav A Date: Tue Jan 10 14:05:01 2023 +0300 fix tabulation for multiple scriptlets --- scripts/build-docs.js | 2 +- src/scriptlets/prevent-addEventListener.js | 13 +++--- src/scriptlets/prevent-window-open.js | 22 +++++----- src/scriptlets/remove-cookie.js | 13 +++--- src/scriptlets/trusted-click-element.js | 1 + wiki/about-scriptlets.md | 48 +++++++++++----------- wiki/about-trusted-scriptlets.md | 13 +++--- 7 files changed, 59 insertions(+), 53 deletions(-) diff --git a/scripts/build-docs.js b/scripts/build-docs.js index 6ce574322..042c33f57 100644 --- a/scripts/build-docs.js +++ b/scripts/build-docs.js @@ -107,7 +107,7 @@ const getMarkdownData = (dataItems) => { }) => { acc.list.push(`* [${name}](#${name})${EOL}`); - const typeOfSrc = type === 'scriptlet' ? 'Scriptlet' : 'Redirect'; + const typeOfSrc = type.toLowerCase().includes('scriptlet') ? 'Scriptlet' : 'Redirect'; const body = `### ⚡️ ${name} ${description}${EOL} diff --git a/src/scriptlets/prevent-addEventListener.js b/src/scriptlets/prevent-addEventListener.js index b821bb229..d8c655ace 100644 --- a/src/scriptlets/prevent-addEventListener.js +++ b/src/scriptlets/prevent-addEventListener.js @@ -28,21 +28,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 154a039f8..b28a1a094 100644 --- a/src/scriptlets/prevent-window-open.js +++ b/src/scriptlets/prevent-window-open.js @@ -48,36 +48,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 e9cbcfe7a..a9f127a6f 100644 --- a/src/scriptlets/remove-cookie.js +++ b/src/scriptlets/remove-cookie.js @@ -19,16 +19,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 927fddf5f..65bd4e2a4 100644 --- a/src/scriptlets/trusted-click-element.js +++ b/src/scriptlets/trusted-click-element.js @@ -25,6 +25,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..64599da1c 100644 --- a/wiki/about-scriptlets.md +++ b/wiki/about-scriptlets.md @@ -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) * * * @@ -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) * * * From 4e560efaeea202dbbc048a21c1999f0e18cc948d Mon Sep 17 00:00:00 2001 From: Atlassian Bamboo Date: Tue, 10 Jan 2023 15:07:12 +0300 Subject: [PATCH 4/6] skipci: Automatic increment build number --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c8957f133..1cd12892d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@adguard/scriptlets", - "version": "1.7.21", + "version": "1.7.22", "description": "AdGuard's JavaScript library of Scriptlets and Redirect resources", "scripts": { "build": "babel-node bundler.js", From 515a563ef130026448d9b0e4751798334a26db42 Mon Sep 17 00:00:00 2001 From: Slava Leleka Date: Thu, 12 Jan 2023 13:44:22 +0300 Subject: [PATCH 5/6] fix some scriptlets wiki page anchors Squashed commit of the following: commit 1facb64310dd22b80d17244e3144200b0f9741c8 Author: Slava Leleka Date: Wed Jan 11 19:55:16 2023 +0200 update scriptlets wiki page commit 34a54f9df5e3d0b2f357d2d0abe10fe9ff837164 Author: Slava Leleka Date: Wed Jan 11 19:54:54 2023 +0200 fix build docs script --- scripts/build-docs.js | 6 ++++-- wiki/about-scriptlets.md | 28 ++++++++++++++-------------- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/scripts/build-docs.js b/scripts/build-docs.js index 042c33f57..0cc8367e3 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.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/wiki/about-scriptlets.md b/wiki/about-scriptlets.md index 64599da1c..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. @@ -878,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 `!`; @@ -946,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 `!`; @@ -1048,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 `!`; From b350a74e21d2734b3be6c4b359c92a217217875a Mon Sep 17 00:00:00 2001 From: Atlassian Bamboo Date: Thu, 12 Jan 2023 13:44:34 +0300 Subject: [PATCH 6/6] skipci: Automatic increment build number --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1cd12892d..f2aae46f9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@adguard/scriptlets", - "version": "1.7.22", + "version": "1.7.23", "description": "AdGuard's JavaScript library of Scriptlets and Redirect resources", "scripts": { "build": "babel-node bundler.js",