1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-07-08 12:57:57 +02:00
Commit Graph

1240 Commits

Author SHA1 Message Date
Raymond Hill
9d3acd91b8
Support AdGuard's [trusted-]set-cookie-reload scriptlets
Related issue:
https://github.com/uBlockOrigin/uBlock-issues/issues/2881
2023-10-18 09:48:08 -04:00
Raymond Hill
b0fe6d228a
Use @latest instead of @main for jsDelivr CDN 2023-10-17 23:25:06 -04:00
Raymond Hill
51359c6585
[experimental] Add json-stringify scriptlet
Will be evaluated this current dev cycle and as a result
might be removed before next stable.

Other changes to increase code consistency.
2023-10-17 17:33:49 -04:00
Raymond Hill
f122ce7320
Add logging ability to trusted-click-element
If the vararg `, log, 1` is present, the scriptlet will log to
the console it's execution steps. Works only in dev build.
2023-10-16 19:53:48 -04:00
Raymond Hill
5a24fad8ad
Make fine-tuned json-prune-[...] scriptlets the default behavior
As discussed with filter list maintainers.
2023-10-16 19:36:16 -04:00
Raymond Hill
7c660b2aad
Remove stray tab 2023-10-15 16:40:35 -04:00
Raymond Hill
c0d80ac510
Fine tune trusted-click-element scriptlet 2023-10-15 16:14:44 -04:00
Raymond Hill
7af88b025d
Add trusted-click-element scriptlet
Implemented as per AdGuard API documentation:
https://github.com/AdguardTeam/Scriptlets/blob/master/wiki/about-trusted-scriptlets.md#trusted-click-element

The current implementation in uBO does not support the `extraMatch`
argument. If the extraMatch argument is not empty, the scriptlet
will abort and do nothing.

As for the rest, it complies with the documentation.
2023-10-15 11:08:15 -04:00
Raymond Hill
17d30343c5
Use safe Array.from() in no-xhr-if scriptlet
Related issue:
https://github.com/uBlockOrigin/uAssets/issues/20063
2023-10-14 08:03:29 -04:00
Raymond Hill
e5c1b63315
Fix overzealous matching in (remove|replace)-node-text scriptlets
Related issue:
https://github.com/uBlockOrigin/uBlock-issues/issues/2868
2023-10-13 21:51:13 -04:00
Raymond Hill
6f74df942d
Fix no-xhr-if scriptlet for Firefox
Related feedback:
https://github.com/uBlockOrigin/uAssets/issues/20063#issuecomment-1762157408
2023-10-13 21:24:21 -04:00
Raymond Hill
780383faef
Use safe versions of Math.floor/Math.random in scriptlets
Related issue:
https://github.com/uBlockOrigin/uBOL-home/issues/78
2023-10-09 09:45:26 -04:00
Raymond Hill
ad75b1bdba
Remove unreferenced dependencies
Related commit:
d4918c1d0a
2023-10-07 13:48:28 -04:00
Raymond Hill
d4918c1d0a
Add version vararg to [...]-fetch-response scriptlets
If the `version` vararg is present and set to `2`, and if a
fetch Request argument is present, it will be cloned before
being matched to `propsToMatch` properties.

Additionally, created a `.fn` version of `[...]-fetch-response`
scriptlets to avoid redundant code in final injected scriptlets.
2023-10-07 11:49:17 -04:00
Raymond Hill
6b211f622c
Add stackToMatch vararg to json-prune-related scriptlets
As per discussion with filter list maintainers.
2023-10-05 11:24:35 -04:00
Raymond Hill
d3b95c1c68
Add site-specific scriptlet
Related issue:
https://github.com/uBlockOrigin/uAssets/issues/19903
2023-09-29 12:51:44 -04:00
Raymond Hill
1ff3878a49
Add prevent-canvas scriptlet
Prevent usage of specific or all (default) canvas APIs.

Syntax

```text
example.com##+js(prevent-canvas [, contextType])
```

- `contextType`: A specific type of canvas API to prevent (default to all
  APIs). Can be a string or regex which will be matched against the type
  used in getContext() call. Prepend with `!` to test for no-match.

Examples

1. Prevent `example.com` from accessing all canvas APIs

```adblock
example.com##+js(prevent-canvas)
```

2. Prevent access to any flavor of WebGL API, everywhere

```adblock
*##+js(prevent-canvas, /webgl/)
```

3. Prevent `example.com` from accessing any flavor of canvas API except `2d`

```adblock
example.com##+js(prevent-canvas, !2d)
```

References

https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/getContext
2023-09-28 11:26:45 -04:00
Raymond Hill
4e2aa3e384
Add scriptlet aliases for compatibility with AdGuard lists
Related issue:
https://github.com/uBlockOrigin/uBlock-issues/issues/2828
2023-09-28 10:07:03 -04:00
Raymond Hill
c3cd596175
Remove unmaintained urlhaus PUP filter list
Related issue:
https://github.com/uBlockOrigin/uBlock-issues/issues/2844
2023-09-28 09:49:07 -04:00
Raymond Hill
402e2ebf57
Use AG version of urlhaus list
Related discussion:
https://github.com/uBlockOrigin/uAssets/issues/7636#issuecomment-1735697402
2023-09-26 16:20:01 -04:00
Raymond Hill
cce3f3efc1
Minor code review of scriptlets 2023-09-22 09:33:02 -04:00
Daylin Cooper
ce959164bb
Fix XHR hook partial response handling. 2023-09-18 23:39:17 -07:00
Raymond Hill
98e1b264de
Update scriptlets
Allow smaller multipliers in nano-sib/nano-stb
https://github.com/uBlockOrigin/uBlock-issues/issues/2808

Remove adfly-defuser, which is now unused.
2023-09-14 11:13:58 -04:00
Raymond Hill
d5fb3c08a1
Remove broken content link for ROU list 2023-09-10 16:10:04 -04:00
Raymond Hill
b2d8c9a0ba
Drop cdn.statically.io for quick-fixes for the time being 2023-09-08 09:35:19 -04:00
Raymond Hill
14d60ac5d3
Fix json-prune-xhr-response as per feedback
Related commit:
abe41034f6
2023-09-06 13:04:43 -04:00
Raymond Hill
abe41034f6
Change approach to ...-xhr-response scriptlets
Related commit:
3152896d42
2023-09-05 14:11:33 -04:00
Raymond Hill
3152896d42
Add json-prune-xhr-response and trusted-replace-xhr-response scriptlets
As discussed with filter list maintainers.

Related issue:
https://github.com/uBlockOrigin/uBlock-issues/issues/2743
2023-09-04 14:54:57 -04:00
Raymond Hill
2282215e1c
Use globalThis instead of self in scriptlet helper
Related discussion:
https://github.com/uBlockOrigin/uBlock-issues/discussions/2768
2023-08-25 07:28:50 -04:00
Raymond Hill
4fc8eef1c1
Fix typo in last commit 2023-08-23 09:45:58 -04:00
Raymond Hill
749cec0f09
Add json-prune-fetch-response scriptlet
As per request from filter list maintainers.

Usage:

  ...##+js(json-prune-fetch-response, prune paths [, needle paths [, ...varargs ]])

See `json-prune` scriptlet for usage.

Possible variable arguments:

  ..., log, [match | nomatch | all]
  ..., propsToMatch, [see prevent-xhr]
2023-08-23 08:49:22 -04:00
Raymond Hill
f407c28a00
Re-factor extra args for set-constant scriptlet
To prepare for better compatibility with AdGuard's own `set-constant`
scriptlet.

The 3rd position parameter which dictates how to set the value has
been converted into a vararg paramater, as follow:

  ..., as, function
  ..., as, callback
  ..., as, resolved
  ..., as, rejected

Similarly, the parameter used to dictate when the scriptlet
should become effective is now to be used as a vararg:

  ..., runAt, load

Related issue:
https://github.com/uBlockOrigin/uBlock-issues/issues/2783

Ideally, AdGuard would support its `stack` parameter as a
vararg, to be discussed.
2023-08-22 10:12:08 -04:00
Raymond Hill
4b83101ab9
Fix/improve xml-prune scriptlet
Related issue:
https://github.com/uBlockOrigin/uAssets/issues/14849#issuecomment-1257094491
2023-08-20 08:36:16 -04:00
Raymond Hill
b699691e40
Minor code review of scriptlets 2023-08-19 19:21:22 -04:00
Raymond Hill
62f2a3e68d
Fix broken mapping between scriptlet aliases and canonical name
Related commit:
bf591d93fb
2023-08-14 13:09:19 -04:00
Raymond Hill
bf591d93fb
Imrpove no-xhr-if scriptlet
Related issue:
https://github.com/uBlockOrigin/uBlock-issues/issues/2773

The `randomize` paramater introduced in https://github.com/gorhill/uBlock/commit/418087de9c
is now named `directive`, and beside the `true` value which is meant
to respond with a random 10-character string, it can now take the
following value:

  war:[web_accessible_resource name]

In order to mock the XHR response with a web accessible resource. For
example:

  piquark6046.github.io##+js(no-xhr-if, adsbygoogle.js, war:googlesyndication_adsbygoogle.js)

Will cause the XHR performed by the webpage to resolve to the content
of `/web_accessible_resources/googlesyndication_adsbygoogle.js`.

Should the resource not exist, the empty string will be returned.
2023-08-14 10:03:50 -04:00
Raymond Hill
418087de9c
Improve no-xhr-if scriptlet
Now support AdGuard's `randomize` parameter. If `true`,
the scriplet will generate a random 10-character string
to be returned as the response.

Reference:
https://github.com/AdguardTeam/Scriptlets/blob/master/wiki/about-scriptlets.md#prevent-xhr

AdGuard's `prevent-xhr` also support `length:n-m` form,
but since I do not see it being used, for now it's not
supported in uBO's `no-xhr-if`.

Additionally, the scriptlet will now honor `responseType` and
return the proper response type accordingly.
2023-08-13 13:23:41 -04:00
Raymond Hill
ef865bea19
Add more info to logged output 2023-08-09 11:18:04 -04:00
Raymond Hill
cfac880cf5
Improve logging abilities of object-prune.fn 2023-08-09 11:05:53 -04:00
Raymond Hill
b4ffd16db6
Fix/improve logging in json-prune scriptlet 2023-08-09 08:02:45 -04:00
Raymond Hill
2c04b5a982
Add ability to distinguish trapped entry point in json-prune 2023-08-08 12:30:42 -04:00
Raymond Hill
4f082a96bc
Support negated pattern for *[pP]ropsToMatch values in scriptlets 2023-08-08 12:20:03 -04:00
Raymond Hill
f8394ff2d5
Add variable argument fetchPropsToMatch to json-prune scriptlet
`fetchPropsToMatch` is an optional variable argument. If provided,
the scriplet will take effect only when the JSON data is obtained
through `Response.json()` and if there is a match with the value of
`fetchPropsToMatch` and the properties of the `Response` instance.

Examples of usage:

...##+js(json-prune, ads, , , fetchPropsToMatch, ?param=)
...##+js(json-prune, ads, , , fetchPropsToMatch, url:?param= method:get)

The optional variable argument `fetchPropsToMatch` acts as an additional
narrowing condition to fulfill before the JSON data is pruned.
2023-08-08 10:18:34 -04:00
Raymond Hill
8bf1ed954d
Move often-used scriptlet dependencies to safe-self 2023-08-08 07:41:21 -04:00
Raymond Hill
1762ea3950
Generate new Response when no match in trusted-replace-fetch-response scriptlet
Somehow, sending the original Response instance causes issues.
2023-08-07 13:06:54 -04:00
Raymond Hill
d28b715811
Fix broken trusted-replace-fetch-response when using propsToMatch 2023-08-07 10:37:47 -04:00
Raymond Hill
2c2fd5f21d
Improve trusted-replace-fetch-response as per feedback
Specifically, the variable argument `log` can take one of three
values to enable logging mechanism:

  ..., log, match => log only when there is a match
  ..., log, nomatch => log only when there is no match
  ..., log, all => log unconditionally
2023-08-06 11:19:10 -04:00
Raymond Hill
60fcdf8e71
Update main URL of urlhaus lists
Related issue:
https://github.com/uBlockOrigin/uBlock-issues/issues/2766
2023-08-06 09:19:35 -04:00
Raymond Hill
7de61bb4d8
Fix broken "Phishing URL Blocklist" URL
Related feedback:
https://www.reddit.com/r/uBlockOrigin/comments/15iwvqi/
2023-08-05 12:38:10 -04:00
Raymond Hill
82a7d11f78
Add trusted-replace-fetch-response scriptlet
This scriplet requires a trusted source.

Related issue:
https://github.com/uBlockOrigin/uBlock-issues/issues/2742

See AdGuard's documentation for usage:
https://github.com/AdguardTeam/Scriptlets/blob/master/wiki/about-trusted-scriptlets.md#trusted-replace-fetch-response
2023-08-05 11:55:47 -04:00