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

1216 Commits

Author SHA1 Message Date
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
Raymond Hill
64b849ab0b
Harden spoof-css scriptlet 2023-08-02 11:36:54 -04:00
Raymond Hill
84cc69aa10
Support negated pattern for stack test in scriptlets
Prepend pattern with `!` to test for unmatched patterns in
stack trace. This applies to sctiplet parameters which purpose
is to test against the stack, i.e. `aost` and `json-prune`.

Additionally, dropped support for JSON notation in favor of
optional variable arguments notation.

Related discussion:
- https://github.com/uBlockOrigin/uBlock-discussions/discussions/789#discussioncomment-6520330
2023-07-31 09:38:04 -04:00
Raymond Hill
81b2fcee5d
Fine tune logging capabilities of json-prune scriptlet
This extends logging capabilities of `json-prune` scriptlet as
follow:

  ...##+js(json-prune, a, b, stackNeedle, log, [logneedle], logstack, 1)

Whereas before, the only way to log `json-prune` usage was to skip
providing the property chain:

  ...##+js(json-prune, , b)

Where `b` was the expression to filter out logging output.

With the extended logging capabilities, the logging output can
be filtered out with `logneedle`, which can be a regex literal.

Additionally, to log the stack trace the `stackNeedle` argument
must be set to non-empty string. You can use `/.^/` to log the
stack trace without matching it.
2023-07-29 10:22:52 -04:00
Raymond Hill
bc74ea82af
Deploy changes in assets.dev.json to assets.json
Related commit:
- https://github.com/gorhill/uBlock/commit/f6954430d197
2023-07-28 11:16:59 -04:00
Raymond Hill
4649ae4d78
Add stackNeedle argument to json-prune scriptlet
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2757
2023-07-27 09:41:56 -04:00
Raymond Hill
6d7674e69f
Improve logic to detect XMLDocument response in xml-prune
Related discussion:
- https://github.com/uBlockOrigin/uBlock-discussions/discussions/792#discussioncomment-6561841

Additionally, added extra parameter `..., logdoc, 1` to allow dumping whole
document being worked on to the console.
2023-07-27 08:39:28 -04:00
Raymond Hill
ba31d3c898
Convert abort-current-script to variable paramater list
Related feedback:
- https://github.com/uBlockOrigin/uAssets/discussions/19154
2023-07-25 09:22:47 -04:00
Raymond Hill
334a7440f3
Improve xml-prune scriptlet
Related feedback:
- https://github.com/uBlockOrigin/uBlock-discussions/discussions/792#discussioncomment-6536598
2023-07-25 09:06:54 -04:00
Raymond Hill
fa489fdb87
Improve remove-class behavior
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2750
2023-07-24 07:33:33 -04:00
Viktor Szépe
c23a9ada33
Fix typos 2023-07-23 10:01:08 -04:00
Raymond Hill
8ddad9e39b
Add $currentISODate$ to trusted-set-local-storage-item scriptlet
Related feedback:
- https://github.com/uBlockOrigin/uAssets/issues/19120#issuecomment-1646524557

Additionally, improve logging in `m3u-prune` scriptlet.
2023-07-22 07:57:47 -04:00
peace2000
da8fe2f950
Add 'deny' as valid value for set-cookie (#3897)
AG added it as well.

6f36f888bb
2023-07-22 06:31:27 -04:00
Raymond Hill
03d0d8d4ce
Eliminate case-sensitivity from values in set-cookie scriptlet
Related discussion:
- https://github.com/uBlockOrigin/uAssets/discussions/18762#discussioncomment-6338716

Additionally, add `allow` as valid value.
2023-07-20 07:53:14 -04:00
Raymond Hill
ee0649329c
Remove obsolete web_accessible_resources
Add removed resource as an alias of `no-window-open-if.js`.

Related discussion:
- https://github.com/uBlockOrigin/uAssets/issues/19002#issuecomment-1638367659
2023-07-18 09:39:06 -04:00
Raymond Hill
ec06981965
Improve compatibility with AdGuard's scriptlets
Related:
https://testcases.agrd.dev/Filters/scriptlet-rules/test-scriptlet-rules.html
2023-07-11 18:25:21 -04:00
Raymond Hill
6e78ee096a
Fix handling of empty strings for set/set-attr scriptlets
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2729
2023-07-11 15:10:27 -04:00
Raymond Hill
786d9b2212
Add set-attr scriptlet
Reference:
- https://github.com/AdguardTeam/Scriptlets/blob/master/src/scriptlets/set-attr.js

Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2347
2023-07-06 08:51:31 -04:00
Raymond Hill
fea6f7f311
Do not bail too early when trapping properties in acs scriptlet
Related feedback:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2130#issuecomment-1621684566
2023-07-05 10:00:31 -04:00
Raymond Hill
083a318090
Add set-session-storage-item scriptlet
Reference:
- https://github.com/AdguardTeam/Scriptlets/blob/master/src/scriptlets/set-session-storage-item.js
2023-07-04 07:13:22 -04:00
Raymond Hill
1f57822c33
Add Accept/Reject as valid values for set-cookie scriptlet
Related discussion:
- https://github.com/uBlockOrigin/uAssets/discussions/18762
2023-07-01 10:25:19 -04:00
Raymond Hill
e0b4b3d830
Add alias for scriptlet to increase compatibility with AdGuard filter lists 2023-07-01 10:20:23 -04:00
Raymond Hill
b283d6aa33
Add support to remove values in set-local-storage-item scriptlet
Related feedback:
- https://github.com/uBlockOrigin/uBlock-issues/discussions/2697#discussioncomment-6278359

When using the special value `$remove$`, the scriptlet will remove
the item from the local storage.
2023-06-30 09:03:17 -04:00
Raymond Hill
fd036a51ee
Add compatibility with AdGuard's #%#//scriptlet(...) syntax
Related issue:
- https://github.com/AdguardTeam/Scriptlets/issues/332

Additionally, uBO's own scriplet syntax now also accept quoting
the parameters with either `'` or `"`. This can be used to avoid
having to escape commas when they are present in a parameter.
2023-06-28 19:35:22 -04:00
Raymond Hill
e0b3b44080
Skip regex-testing context when no context provided
Related issue:
- https://github.com/uBlockOrigin/uAssets/issues/18725

Testing the context was causing the deprecated static property
RegExp.$1 to be clobbered, causing webpage breakage because this
property was subsequently used used by the caller.
2023-06-28 18:12:17 -04:00