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

1096 Commits

Author SHA1 Message Date
Raymond Hill
349c8ca619
Fix overzealous logging in acs scriptlet 2023-04-23 09:28:59 -04:00
Raymond Hill
2ab2b48066
Updated the Finnish list source address (#3894)
Co-authored-by: peace2000 <17256841+peace2000@users.noreply.github.com>
2023-04-18 09:46:33 -04:00
Raymond Hill
cc062d3a8a
No need for redundant "safe" 2023-04-15 11:14:14 -04:00
Raymond Hill
e1500ee88d
Add ability to defer set-constant execution
A new optional parameter has been added to `set-constant`
scriptlet: `runAt`, default to `0`.

 ..##+js(set, document.body.oncontextmenu, null, 2)

When the `runAt` parameter is present, uBO will take it into
account to possibly defer execution of `set-constant`:

- `runAt` not present: execute immediately
- `runAt` = 1: execute immediately
- `runAt` = 2: execute when document state is "interactive"
- `runAt` = 3: execute when document state is `"complete"
2023-04-11 21:45:40 -04:00
Raymond Hill
edbe96a401
Add logging ability to acs scriptlet, for the benefit of filter list
maintainers.

To enable logging, use the JSON approach to pass parameters to
`acs` scriptlet. Example:

    ..##+js(acs, { "target": "document.oncontextmenu", "log": true })

Whereas "target", "needle", and "context" correspond to their
respective positional argument. Using JSON form to pass parameters
allows to specify extra paramters to facilitate debugging of that
scriptlet:

- `"log": true` => output useful information at the dev console.
- `"debug": true` => break at key locations in the scriptlet.

The added logging/debugging capabilities work only in the dev build
of uBO or if the advanced setting `filterAuthorMode` is set to
`true`.
2023-04-02 12:01:58 -04:00
Raymond Hill
b5d78a07bf
Fix type in variable name
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2570
2023-03-30 20:46:44 -04:00
Raymond Hill
c8af55e27a
Harden aeld scriptlet against page's tampering
Related feedback:
- https://github.com/uBlockOrigin/uBlock-discussions/discussions/1#discussioncomment-5433222
2023-03-26 14:02:21 -04:00
Raymond Hill
5c9c87e485
Add ability for scriptlets to share local data
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1741

As a result of the new capability, usage of RegExp API in `aost`
scriptlet has been shielded from the webpage tampering with the
API.
2023-03-26 12:31:36 -04:00
Raymond Hill
236fb3ad59
Add scriptlet dependencies to reduce code duplication 2023-03-26 09:13:17 -04:00
Raymond Hill
439951824a
Remove addEventListenerLogger, expand addEventListenerDefuser
The scriptlet addEventListenerLogger has been removed.

The logging of addEventListener() calls can now be done with the
addEventListenerDefuser scriptlet, which now supports the
following named arguments:

"type": the event type to match. Default to '', i.e. match-all.

"pattern": the pattern to match against the handler argument
Default to '', i.e. match-all.

"log": an integer value telling when to log:

- 1: log only when both type and pattern matches, i.e. when a
     call to addEventListener() is defused
- 2: log when either the type or pattern matches
- 3: log all calls to addEventListener()

"debug": an integer value telling when to break into the
 debugger, useful to inspect the debugger's call stack.

- 1: break into the debugger when both type and pattern match,
     so effectively when defusing is taking place.
- 2: break into the debugger when either type or pattern matches.

The usage of named arguments is optional, positional arguments
are still supported as documented. Named arguments is required
to use "log" and/or "debug" arguments.

Obviously, do not use "log" or "debug" in any filter list, these
are investigative tools for filter list authors.

Examples of usage using named arguments:

  wikipedia.org##+js(aeld, { "type": "/mouse/", "pattern": "/.^/", "log": 2 })

Above filter will log calls to addEventListener() which have the
pattern "mouse" in the event type (so "mouseover", "mouseout",
etc.) without defusing any of them (because pattern can't match
anything).

  wikipedia.org##+js(aeld, { "type": "/.^/", "log": 2 })

Above filter will log all calls without defusing any of them
(because type can't match anything)

  wikipedia.org##+js(aeld, { "log": 1 })

Above filter will log and defuse all calls to addEventListener().
2023-03-25 12:35:56 -04:00
Raymond Hill
a51130baed
Remove unused scriptlets 2023-03-24 18:46:39 -04:00
Raymond Hill
18a84d2819
Refactor scriptlets injection code
Builtin scriptlets are no longer parsed as text-based resources,
they are imported as JS functions, and `toString()` is used to
obtain text-based representation of a scriptlet.

Scriptlet parameters are now passed as function call arguments
rather than by replacing text-based occurrences of `{{i}}`. The
arguments are always string values (see below for exception).

Support for argument as Object has been added. This opens the
door to have scriptlets using named arguments rather than
positional arguments, and hence easier to extend functionality
of existing scriptlets. Example:

    example.com##+js(scriplet, { "prop": "adblock", "value": false, "log": true })

Compatibility with user-provided scriptlets has been preserved.

User-provided scriptlets can benefit some of the changes:

Use the form `function(..){..}` instead of `(function(..){..})();`
in order to received scriptlet arguments as part of function call
-- instead of using `{{i}}`.

If using the form `function(..){..}`, you can choose to receive
an Object as argument -- just be sure that your scriptlet's
parameter is valid JSON notation.
2023-03-24 14:05:18 -04:00
Raymond Hill
285ce54d9c
Add regional filter list for Croatia/Serbia
Related discussion:
- https://github.com/uBlockOrigin/uAssets/issues/17088#issuecomment-1460942565
2023-03-21 09:56:43 -04:00
Raymond Hill
e93117cbb6
Add call-nothrow scriptlet
The purpose is to prevent a call to an existing function from
throwing an exception. The exception will be caught by the
scriptlet and neutralized.

The first argument must be a reference to a function call. At
the moment, the function call must exist at the time the
scriptlet is called.
2023-03-14 18:50:01 -04:00
Raymond Hill
5fe0416001
Fix https://github.com/uBlockOrigin/uBlock-issues/issues/2546 2023-03-14 14:05:20 -04:00
Raymond Hill
fc84fdee52
Fine tune scriptlet 2023-03-14 08:21:22 -04:00
Raymond Hill
b3821e6869
Support removing whole lines of text with regex in m3u-prune scriptlet
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2508

If the first argument is a regex with multine flag set, the
scriptlet will execute the regex against the whole text, and
remove matching text from the whole text.

If the matching text does not contains whole lines, the text
won't be removed, i.e. it is not allowed to remove only part
of a line.
2023-03-12 17:45:02 -04:00
Raymond Hill
f80c84ab40
Remove references to deprecated gitcdn.link
Related feedback:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2136#issuecomment-1465231197
2023-03-12 14:09:44 -04:00
Raymond Hill
4b4ef6a60c
Rename href-from-text to href-sanitizer, add argument
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2531#issuecomment-1462389539

Usage:
- example.com##+js(href-sanitizer, a[href^="/go?to="]:not([title]))
- example.com##+js(href-sanitizer, a[href^="/go?to="][title], [title])

The second argument is the attribute from which to extract the text
to be used for the `href` attribute of the link. If the second
attribute is absent, the text content of the element will be used.
2023-03-09 13:37:06 -05:00
Raymond Hill
e123256eaf
Add experimental href-from-text scriptlet
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2531

Usage:

    example.com##+js(href-from-text, a[href^="/tracker-link?to="]

The above scriptlet will find all elements matching the selector
passed as 1st argument, and replace the `href` attribute with the
text content of the element, if all the following conditions are
met:

- The element is a link (`a`) element
- The link element has an existing `href` attribute
- The text content of the element is a valid `https`-based URL
2023-03-09 08:49:26 -05:00
Raymond Hill
088e90ed42
Add list for Macedonia; add languages to Persian list
Related issues:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2522
- https://github.com/AdguardTeam/AdguardFilters/pull/144318#issuecomment-1451721914
2023-03-02 17:09:32 -05:00
Raymond Hill
46c1eb8678
Update URLs to EasyDutch list
Related feedback:
- https://github.com/uBlockOrigin/uAssets/issues/11204#issuecomment-1384238094
2023-01-23 20:04:01 -05:00
Raymond Hill
98c0bd8406
Remove AdGuard Tracking Protection from stock lists
Related issue:
- https://github.com/AdguardTeam/AdguardFilters/issues/139081#issuecomment-1375396423
2023-01-11 20:29:07 -05:00
Raymond Hill
eb88e6fb12
Fix bad JSON 2022-12-26 09:11:04 -05:00
Raymond Hill
8f66de67e1
Remove gitcdn.link as CDN provider
Appears broken at the moment. Related discussion:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1165#issuecomment-1364607559
2022-12-25 07:40:13 -05:00
Raymond Hill
c88f4445d1
Update invalid SDN URL for EasyList Lithuania
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2420
- https://github.com/uBlockOrigin/uBlock-issues/issues/1566#issuecomment-826372745
2022-12-22 10:34:49 -05:00
Raymond Hill
6140e55589
Remove combinatronics.io as CDN 2022-12-02 11:39:32 -05:00
Raymond Hill
17590c5a0c
Use git clone instead of submodule to pull uAssets dependencies
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2358

We need two different branches of uAssets to properly add the
default filter lists into the packages. I couldn't figure out
how to do this with submodules, using simple `git clone` as a
dependency just work.
2022-11-14 09:50:53 -05:00
Raymond Hill
2f646dbdb0
Pull reference Easylist assests from own repo 2022-10-24 12:37:04 -04:00
Raymond Hill
e84b374279
Partially revert fd945f3358 2022-10-19 18:17:39 -04:00
Raymond Hill
83b9ca5db6
Don't use github as cdn for EasyList/EasyPrivacy 2022-10-17 17:21:01 -04:00
Raymond Hill
fd945f3358
Add mirrors for EasyList lists 2022-10-05 10:37:33 -04:00
Raymond Hill
ec83127f6c
Update m3u-prune scriptlet 2022-09-26 22:37:11 -04:00
Raymond Hill
115f7bb687
Fix operator token-to-ctor map
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2294
2022-09-26 22:27:50 -04:00
Raymond Hill
6828e1c3b2
Bail out early if missing required argument 2022-09-25 06:57:51 -04:00
Raymond Hill
596145ceb9
Harden xml-prune scriptlet 2022-09-25 06:49:41 -04:00
Raymond Hill
bf690145c4
Add new scriptlet: xml-prune
Related issue:
- https://github.com/uBlockOrigin/uAssets/issues/14849

Arguments:

1. Required. The selector of elements which are to be removed.
   Example: Period[id*="-roll-"][id*="-ad-"]

2. An optional selector that must have a match in the document
   for the pruning to occur. No selector means the pruning can
   be performed regardless.

3. An optional URL which must be a match for the pruning to
   occur. If left blank, the pruning can be performed regardless.
2022-09-24 20:49:00 -04:00
Raymond Hill
fe21ce5002
Ease load on EasyList server
Related discussion:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2276#issuecomment-1254387437
2022-09-22 05:52:47 -04:00
Imre Kristoffer Eilertsen
3ea8142d9e
Adding "LKA" for Sri Lanka and "NPL" for Nepal to IndianList's title (#3866)
* Added "LKA" for Sri Lanka to IndianList's title

* Added NPL for Nepal too

After seeing that IndianList already supports Nepal languages outright.
2022-09-18 07:17:45 -04:00
Raymond Hill
65a0561072
Slightly change behavior of window-close-if scriplet
Related discussion:
- https://github.com/uBlockOrigin/uBlock-issues/discussions/2270

If the argument to the window-close-if scriptlet is a regex, the
match will be against the whole location URL, otherwise the
match will be against the part+query part of the location URL.
2022-09-17 12:46:42 -04:00
Raymond Hill
424797a0b1
Fix/add support URLs for uBO's own lists 2022-09-14 09:29:49 -04:00
Raymond Hill
78fccadaf2
Fix bad alias
Related feedback:
- https://github.com/DandelionSprout/adfilt/issues/63#issuecomment-1214131551
2022-08-13 09:09:36 -04:00
Raymond Hill
ac0cdf2d56
Update URL of new RUAdList location
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2193
2022-08-01 17:53:02 -04:00
Raymond Hill
cb65b2a122
Update URLs for Latvian (LVA-0) list
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2176
2022-07-17 12:59:23 -04:00
Raymond Hill
9d81b7c4d9
Skip testing context when none present in acis scriptlet
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2154
2022-06-24 13:35:20 -04:00
Raymond Hill
dddf353c94
Use hard tab 2022-06-19 11:55:06 -04:00
Raymond Hill
33b839fdd0
Replace Adblock-Iran with PersianBlocker
Related discussion:
- https://github.com/uBlockOrigin/uAssets/discussions/13259
2022-06-05 09:17:41 -04:00
Ming Di Leom
2ce7f84157
fix(curben-filter): curben.gitlab.io migrated to malware-filter.gitlab.io (#3867) 2022-06-03 12:46:10 -04:00
Raymond Hill
fd3ff0b395
Fix bad content URL for List-KR
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2129

Fixed as suggested in:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2129#issuecomment-1142168643
2022-06-03 12:31:07 -04:00
Raymond Hill
b76d7c6af6
Also dispatch loadend event in case of match
Related issue:
- https://github.com/AdguardTeam/Scriptlets/issues/199
2022-05-08 11:22:32 -04:00