Skip to content

Commit

Permalink
AG-13382 update docs, validate noopjson
Browse files Browse the repository at this point in the history
Squashed commit of the following:

commit 3443e3f
Author: Slava Leleka <v.leleka@adguard.com>
Date:   Tue Mar 22 17:19:11 2022 +0300

    add noopjson to compatibility-table

commit ec956e1
Author: Slava Leleka <v.leleka@adguard.com>
Date:   Tue Mar 22 17:08:20 2022 +0300

    no pre-commit warning about dist

commit a02c630
Author: Slava Leleka <v.leleka@adguard.com>
Date:   Tue Mar 22 17:06:54 2022 +0300

    fix noopjson validation

commit 56dbb6f
Merge: cfd220b 72e3953
Author: Slava Leleka <v.leleka@adguard.com>
Date:   Tue Mar 22 16:34:50 2022 +0300

    Merge branch 'release/v1.6' into fix/AG-13382

commit cfd220b
Author: Slava Leleka <v.leleka@adguard.com>
Date:   Tue Mar 22 16:29:47 2022 +0300

    update docs

commit 2b77ea7
Author: Slava Leleka <v.leleka@adguard.com>
Date:   Tue Mar 22 15:32:11 2022 +0300

    update compatibility-table.md

commit 0f3e2e3
Author: Slava Leleka <v.leleka@adguard.com>
Date:   Tue Mar 22 15:30:03 2022 +0300

    update compatibility-table.json
  • Loading branch information
slavaleleka committed Mar 22, 2022
1 parent 72e3953 commit c06a8e5
Show file tree
Hide file tree
Showing 7 changed files with 193 additions and 27 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
9 changes: 8 additions & 1 deletion scripts/compatibility-table.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -320,6 +324,9 @@
"ubo": "noop.js",
"abp": "blank-js"
},
{
"adg": "noopjson"
},
{
"adg": "nooptext",
"ubo": "noop.txt",
Expand Down
3 changes: 3 additions & 0 deletions src/helpers/compatibility-redirects.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ const redirects = [
ubo: 'noop.js',
abp: 'blank-js',
},
{
adg: 'noopjson',
},
{
adg: 'nooptext',
ubo: 'noop.txt',
Expand Down
5 changes: 5 additions & 0 deletions tests/lib-tests/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
108 changes: 102 additions & 6 deletions wiki/about-redirects.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* [noopframe](#noopframe)
* [noopcss](#noopcss)
* [noopjs](#noopjs)
* [noopjson](#noopjson)
* [nooptext](#nooptext)
* [empty](#empty)
* [noopvmap-1.0](#noopvmap-1.0)
Expand All @@ -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)
Expand Down Expand Up @@ -90,6 +97,14 @@
[Redirect source](../src/redirects/static-redirects.yml)
* * *

### <a id="noopjson"></a> ⚡️ noopjson
**Example**
```
||example.org/geo/location$xmlhttprequest,redirect=noopjson
```
[Redirect source](../src/redirects/static-redirects.yml)
* * *

### <a id="nooptext"></a> ⚡️ nooptext
**Example**
```
Expand Down Expand Up @@ -192,20 +207,49 @@ https://developers.atinternet-solutions.com/as2-tagging-en/javascript-en/getting
[Redirect source](../src/redirects/ati-smarttag.js)
* * *

### <a id="fingerprintjs"></a> ⚡️ fingerprintjs
### <a id="didomi-loader"></a> ⚡️ 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)
* * *

### <a id="fingerprintjs2"></a> ⚡️ 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)
* * *

### <a id="fingerprintjs3"></a> ⚡️ 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)
* * *

### <a id="gemius"></a> ⚡️ gemius
Expand Down Expand Up @@ -253,6 +297,18 @@ https://github.com/gorhill/uBlock/blob/8cd2a1d263a96421487b39040c1d23eb01169484/
[Redirect source](../src/redirects/google-analytics.js)
* * *

### <a id="google-ima3"></a> ⚡️ 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)
* * *

### <a id="googlesyndication-adsbygoogle"></a> ⚡️ googlesyndication-adsbygoogle

Mocks Google AdSense API.
Expand Down Expand Up @@ -321,6 +377,18 @@ https://yandex.ru/support/metrica/objects/_method-reference.html
[Redirect source](../src/redirects/metrika-yandex-watch.js)
* * *

### <a id="naver-wcslog"></a> ⚡️ 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)
* * *

### <a id="noeval"></a> ⚡️ noeval

Redirects request to the source which sets static properties to PopAds and popns objects.
Expand All @@ -342,6 +410,33 @@ https://github.com/gorhill/uBlock/wiki/Resources-Library#noeval-silentjs-
[Redirect source](../src/redirects/noeval.js)
* * *

### <a id="prebid-ads"></a> ⚡️ 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)
* * *

### <a id="prebid"></a> ⚡️ 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)
* * *

### <a id="prevent-bab"></a> ⚡️ prevent-bab

Prevents BlockAdblock script from detecting an ad blocker.
Expand Down Expand Up @@ -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)
* * *

85 changes: 68 additions & 17 deletions wiki/about-scriptlets.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
* * *
Expand Down Expand Up @@ -560,21 +566,6 @@ example.org#%#//scriptlet('log', 'arg1', 'arg2')
[Scriptlet source](../src/scriptlets/log.js)
* * *
### <a id="no-floc"></a> ⚡️ 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)
* * *
### <a id="noeval"></a> ⚡️ noeval
Prevents page to use eval.
Expand Down Expand Up @@ -680,6 +671,30 @@ example.org#%#//scriptlet('prevent-bab')
[Scriptlet source](../src/scriptlets/prevent-bab.js)
* * *

### <a id="prevent-element-src-loading"></a> ⚡️ 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)
* * *

### <a id="prevent-eval-if"></a> ⚡️ prevent-eval-if

Prevents page to use eval matching payload.
Expand Down Expand Up @@ -780,6 +795,34 @@ example.org#%#//scriptlet('prevent-popads-net')
[Scriptlet source](../src/scriptlets/prevent-popads-net.js)
* * *
### <a id="prevent-refresh"></a> ⚡️ 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)
* * *
### <a id="prevent-requestAnimationFrame"></a> ⚡️ prevent-requestAnimationFrame
Prevents a `requestAnimationFrame` call
Expand Down Expand Up @@ -1120,14 +1163,15 @@ 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:
- 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 - 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.
Expand Down Expand Up @@ -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)
* * *
Expand Down Expand Up @@ -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;
Expand Down
Loading

0 comments on commit c06a8e5

Please sign in to comment.