From c06a8e539488e1ebfcf72c85a39a0ef5b9c028bb Mon Sep 17 00:00:00 2001 From: Slava Leleka Date: Tue, 22 Mar 2022 19:13:40 +0300 Subject: [PATCH] AG-13382 update docs, validate noopjson Squashed commit of the following: commit 3443e3f662b3eda5802353860d9fb5a318b720c5 Author: Slava Leleka Date: Tue Mar 22 17:19:11 2022 +0300 add noopjson to compatibility-table commit ec956e1d8023b3ec22031b02f40308671f48269f Author: Slava Leleka Date: Tue Mar 22 17:08:20 2022 +0300 no pre-commit warning about dist commit a02c63015047d0e34e6359b1604cbaf465c084be Author: Slava Leleka Date: Tue Mar 22 17:06:54 2022 +0300 fix noopjson validation commit 56dbb6f1c42dd6e8c38ea05a685df9f462ac0969 Merge: cfd220b 72e3953 Author: Slava Leleka Date: Tue Mar 22 16:34:50 2022 +0300 Merge branch 'release/v1.6' into fix/AG-13382 commit cfd220bf317d69b82e0c79b27e1328727db6748e Author: Slava Leleka Date: Tue Mar 22 16:29:47 2022 +0300 update docs commit 2b77ea73a6406e0b27a2bc104b819f7e2d656a89 Author: Slava Leleka Date: Tue Mar 22 15:32:11 2022 +0300 update compatibility-table.md commit 0f3e2e3bc15896d8496e200acd25734dc8f3cffb Author: Slava Leleka Date: Tue Mar 22 15:30:03 2022 +0300 update compatibility-table.json --- package.json | 2 +- scripts/compatibility-table.json | 9 ++- src/helpers/compatibility-redirects.js | 3 + tests/lib-tests/index.test.js | 5 ++ wiki/about-redirects.md | 108 +++++++++++++++++++++++-- wiki/about-scriptlets.md | 85 +++++++++++++++---- wiki/compatibility-table.md | 8 +- 7 files changed, 193 insertions(+), 27 deletions(-) diff --git a/package.json b/package.json index bc90408e2..6510d6d29 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,7 @@ }, "husky": { "hooks": { - "pre-commit": "lint-staged && echo \"DO NOT FORGET ABOUT BUILDS UPDATE (yarn prepare-builds)\"" + "pre-commit": "lint-staged" } }, "author": "AdGuard", diff --git a/scripts/compatibility-table.json b/scripts/compatibility-table.json index b13685a86..06e3bdd2d 100644 --- a/scripts/compatibility-table.json +++ b/scripts/compatibility-table.json @@ -271,9 +271,13 @@ "ubo": "click2load.html" }, { - "adg": "fingerprintjs", + "adg": "fingerprintjs2", "ubo": "fingerprint2.js" }, + { + "adg": "fingerprint3js", + "ubo": "fingerprint3.js" + }, { "adg": "google-analytics", "ubo": "google-analytics_analytics.js" @@ -320,6 +324,9 @@ "ubo": "noop.js", "abp": "blank-js" }, + { + "adg": "noopjson" + }, { "adg": "nooptext", "ubo": "noop.txt", diff --git a/src/helpers/compatibility-redirects.js b/src/helpers/compatibility-redirects.js index 110be91e8..1470b6c7e 100644 --- a/src/helpers/compatibility-redirects.js +++ b/src/helpers/compatibility-redirects.js @@ -111,6 +111,9 @@ const redirects = [ ubo: 'noop.js', abp: 'blank-js', }, + { + adg: 'noopjson', + }, { adg: 'nooptext', ubo: 'noop.txt', diff --git a/tests/lib-tests/index.test.js b/tests/lib-tests/index.test.js index 6d5d17f98..c10b05420 100644 --- a/tests/lib-tests/index.test.js +++ b/tests/lib-tests/index.test.js @@ -262,6 +262,11 @@ test('Test $redirect validation', (assert) => { assert.strictEqual(validator.isAdgRedirectRule(inputRule), true); assert.strictEqual(validator.isValidAdgRedirectRule(inputRule), true); + // new noopjson + inputRule = '||example.org^$xmlhttprequest,redirect=noopjson'; + assert.strictEqual(validator.isAdgRedirectRule(inputRule), true); + assert.strictEqual(validator.isValidAdgRedirectRule(inputRule), true); + // check fingerprint redirect inputRule = '||cloudflare.com/ajax/libs/fingerprintjs2/$script,redirect=fingerprint2.js,important'; assert.strictEqual(validator.isAdgRedirectRule(inputRule), true, 'fingerprint2.js -- isAdgRedirectRule returns true'); diff --git a/wiki/about-redirects.md b/wiki/about-redirects.md index 37bd164f7..f14b2e9c3 100644 --- a/wiki/about-redirects.md +++ b/wiki/about-redirects.md @@ -6,6 +6,7 @@ * [noopframe](#noopframe) * [noopcss](#noopcss) * [noopjs](#noopjs) +* [noopjson](#noopjson) * [nooptext](#nooptext) * [empty](#empty) * [noopvmap-1.0](#noopvmap-1.0) @@ -16,16 +17,22 @@ * [noopmp4-1s](#noopmp4-1s) * [amazon-apstag](#amazon-apstag) * [ati-smarttag](#ati-smarttag) -* [fingerprintjs](#fingerprintjs) +* [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) +* [prebid-ads](#prebid-ads) +* [prebid](#prebid) * [prevent-bab](#prevent-bab) * [prevent-bab2](#prevent-bab2) * [prevent-fab-3.2.0](#prevent-fab-3.2.0) @@ -90,6 +97,14 @@ [Redirect source](../src/redirects/static-redirects.yml) * * * +### ⚡️ noopjson +**Example** +``` +||example.org/geo/location$xmlhttprequest,redirect=noopjson +``` +[Redirect source](../src/redirects/static-redirects.yml) +* * * + ### ⚡️ nooptext **Example** ``` @@ -192,20 +207,49 @@ https://developers.atinternet-solutions.com/as2-tagging-en/javascript-en/getting [Redirect source](../src/redirects/ati-smarttag.js) * * * -### ⚡️ fingerprintjs +### ⚡️ didomi-loader -Mocks FingerprintJS. +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/commit/33a18c3a1eb101470c43979a41d8adef3e21208d +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=fingerprintjs +||the-japan-news.com/modules/js/lib/fgp/fingerprint2.js$script,redirect=fingerprintjs2 ``` -[Redirect source](../src/redirects/fingerprintjs.js) +[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 @@ -253,6 +297,18 @@ https://github.com/gorhill/uBlock/blob/8cd2a1d263a96421487b39040c1d23eb01169484/ [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. @@ -321,6 +377,18 @@ https://yandex.ru/support/metrica/objects/_method-reference.html [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. @@ -342,6 +410,33 @@ https://github.com/gorhill/uBlock/wiki/Resources-Library#noeval-silentjs- [Redirect source](../src/redirects/noeval.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. @@ -440,3 +535,4 @@ https://github.com/gorhill/uBlock/blob/1.31.0/src/web_accessible_resources/click ``` [Redirect source](../src/redirects/blocking-redirects/click2load.html) * * * + diff --git a/wiki/about-scriptlets.md b/wiki/about-scriptlets.md index 572513228..91ae54064 100644 --- a/wiki/about-scriptlets.md +++ b/wiki/about-scriptlets.md @@ -17,16 +17,17 @@ * [log-eval](#log-eval) * [log-on-stack-trace](#log-on-stack-trace) * [log](#log) -* [no-floc](#no-floc) * [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) @@ -500,6 +501,11 @@ e.g. 'ad.*.src' instead of 'ad.0.src ad.1.src ad.2.src ...' 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) * * * @@ -560,21 +566,6 @@ example.org#%#//scriptlet('log', 'arg1', 'arg2') [Scriptlet source](../src/scriptlets/log.js) * * * -### ⚡️ no-floc - -Prevents using Google Chrome tracking feature called Federated Learning of Cohorts (aka "FLoC") - -Related UBO scriptlet: -https://github.com/gorhill/uBlock/wiki/Resources-Library#no-flocjs- - -**Syntax** -``` -example.org#%#//scriptlet('no-floc') -``` - -[Scriptlet source](../src/scriptlets/no-floc.js) -* * * - ### ⚡️ noeval Prevents page to use eval. @@ -680,6 +671,30 @@ 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-src', 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. @@ -780,6 +795,34 @@ 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 @@ -1120,7 +1163,7 @@ https://github.com/gorhill/uBlock/wiki/Resources-Library#no-xhr-ifjs- **Syntax** ``` -example.org#%#//scriptlet('prevent-xhr'[, propsToMatch]) +example.org#%#//scriptlet('prevent-xhr'[, propsToMatch[, randomize]]) ``` - propsToMatch - optional, string of space-separated properties to match; possible props: @@ -1128,6 +1171,7 @@ example.org#%#//scriptlet('prevent-xhr'[, propsToMatch]) - 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 - optional, defaults to `false`, boolean to randomize responseText of matched XMLHttpRequest's response, > Usage with no arguments will log XMLHttpRequest objects to browser console; which is useful for debugging but permitted for production filter lists. @@ -1159,6 +1203,11 @@ which is useful for debugging but permitted for production filter lists. 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') + ``` + [Scriptlet source](../src/scriptlets/prevent-xhr.js) * * * @@ -1422,6 +1471,8 @@ example.org#%#//scriptlet('set-constant', property, value[, stack]) - `noopFunc` - function with empty body - `trueFunc` - function returning true - `falseFunc` - function returning false + - `noopPromiseResolve` - function returning Promise object that is resolved with an empty response + - `noopPromiseReject` - function returning Promise.reject() - `''` - empty string - `-1` - number value `-1` - `stack` - optional, string or regular expression that must match the current function call stack trace; diff --git a/wiki/compatibility-table.md b/wiki/compatibility-table.md index 76830ecdf..f904aeaf3 100644 --- a/wiki/compatibility-table.md +++ b/wiki/compatibility-table.md @@ -19,7 +19,7 @@ | [log-addEventListener](../wiki/about-scriptlets.md#log-addEventListener) | addEventListener-logger.js (aell.js) | | | [log-eval](../wiki/about-scriptlets.md#log-eval) | | | | [log-on-stack-trace](../wiki/about-scriptlets.md#log-on-stack-trace) | | | -| [no-floc](../wiki/about-scriptlets.md#no-floc) | no-floc.js | | +| [naver-wcslog](../wiki/about-scriptlets.md#naver-wcslog) | | | | [noeval](../wiki/about-scriptlets.md#noeval) | | | | [nowebrtc](../wiki/about-scriptlets.md#nowebrtc) | nowebrtc.js | | | [prevent-addEventListener](../wiki/about-scriptlets.md#prevent-addEventListener) | addEventListener-defuser.js (aeld.js) | | @@ -70,6 +70,7 @@ | | | abort-on-iframe-property-write | | | abort-current-script.js (acs.js, abort-current-inline-script.js, acis.js) | | | | refresh-defuser.js | | +| | no-floc.js | | # Redirects compatibility table @@ -83,7 +84,8 @@ | [amazon-apstag](../wiki/about-redirects.md#amazon-apstag) | amazon_apstag.js | | | [ati-smarttag](../wiki/about-redirects.md#ati-smarttag) | | | | [click2load.html](../wiki/about-redirects.md#click2load.html) | click2load.html | | -| [fingerprintjs](../wiki/about-redirects.md#fingerprintjs) | fingerprint2.js | | +| [fingerprintjs2](../wiki/about-redirects.md#fingerprintjs2) | fingerprint2.js | | +| [fingerprint3js](../wiki/about-redirects.md#fingerprint3js) | fingerprint3.js | | | [google-analytics](../wiki/about-redirects.md#google-analytics) | google-analytics_analytics.js | | | [google-analytics-ga](../wiki/about-redirects.md#google-analytics-ga) | google-analytics_ga.js | | | [googlesyndication-adsbygoogle](../wiki/about-redirects.md#googlesyndication-adsbygoogle) | googlesyndication_adsbygoogle.js | | @@ -96,12 +98,14 @@ | [noopcss](../wiki/about-redirects.md#noopcss) | | blank-css | | [noopframe](../wiki/about-redirects.md#noopframe) | noop.html | blank-html | | [noopjs](../wiki/about-redirects.md#noopjs) | noop.js | blank-js | +| [noopjson](../wiki/about-redirects.md#noopjson) | | | | [nooptext](../wiki/about-redirects.md#nooptext) | noop.txt | blank-text | | [noopmp3-0.1s](../wiki/about-redirects.md#noopmp3-0.1s) | noop-0.1s.mp3 | blank-mp3 | | [noopmp4-1s](../wiki/about-redirects.md#noopmp4-1s) | noop-1s.mp4 | blank-mp4 | | [noopvmap-1.0](../wiki/about-redirects.md#noopvmap-1.0) | noop-vmap1.0.xml | | | [noopvast-2.0](../wiki/about-redirects.md#noopvast-2.0) | | | | [noopvast-3.0](../wiki/about-redirects.md#noopvast-3.0) | | | +| [prebid-ads](../wiki/about-redirects.md#prebid-ads) | prebid-ads.js | | | [prevent-bab](../wiki/about-redirects.md#prevent-bab) | nobab.js | | | [prevent-bab2](../wiki/about-redirects.md#prevent-bab2) | nobab2.js | | | [prevent-fab-3.2.0](../wiki/about-redirects.md#prevent-fab-3.2.0) | nofab.js | |