Commit Graph

4404 Commits

Author SHA1 Message Date
Raymond Hill c1657c2f9c
Import translation work from https://crowdin.com/project/ublock 2023-10-24 11:22:21 -04:00
Dave Vandyke b445f4f4cd
Improve google-ima shim script (#3899)
We made use of the google-ima shim script from uBlock in the
DuckDuckGo Privacy Essentials extension recently, but found a few
issues with website breakage. After debugging and fixing those[1], I
thought it would be worth sharing the improvements back again. Issues
we ran into:

- The AdDisplayContainer[2] constructor usually creates some DOM
  elements inside the given container. They are all nested within a
  DIV and some websites break when at least that top DIV element isn't
  created.
- While not documented (that I could see), the event listeners can be
  added using an array of event types. Some websites make use of that
  and then hang forever when the expected events aren't fired. This
  caused videos not to play on some websites.
- The Ad.prototype.getUniversalAdIds()[3] method should return an
  array of UniversalAdIdInfo Objects, instead of an Array of
  strings. When an array of strings are returned, some websites then
  break when the UniversalAdIdInfo's methods are missing.
- The UniversalAdIdInfo.prototype.getAdIdValue()[4] method had a typo
  in the name ("getAsIdValue") and was effectively missing. That
  caused some websites to break when the missing method was called.
- The google.ima.OmidVerificationVendor[5] Object was missing, which
  broke some websites that attempted to access it.

1 - 52f2999523
2 - https://developers.google.com/interactive-media-ads/docs/sdks/html5/client-side/reference/js/google.ima.AdDisplayContainer
3 - https://developers.google.com/interactive-media-ads/docs/sdks/html5/client-side/reference/js/google.ima.Ad#getUniversalAdIds
4 - https://developers.google.com/interactive-media-ads/docs/sdks/html5/client-side/reference/js/google.ima.UniversalAdIdInfo#getAdIdValue
5 - https://developers.google.com/interactive-media-ads/docs/sdks/html5/client-side/reference/js/google.ima#.OmidVerificationVendor
2023-10-24 11:16:14 -04:00
Raymond Hill e351551dc4
Move warning sentence to the start
Related discussion:
https://github.com/uBlockOrigin/uBlock-issues/discussions/2895#discussioncomment-7353454
2023-10-23 10:01:33 -04:00
Raymond Hill 6c672c99c2
Import translation work from https://crowdin.com/project/ublock 2023-10-23 09:20:59 -04:00
Raymond Hill 589f281f21
Fine tune CSS
Related discussion:
https://github.com/uBlockOrigin/uBlock-issues/discussions/2895#discussioncomment-7353182
2023-10-22 18:33:28 -04:00
Raymond Hill 1a1876e593
Import translation work from https://crowdin.com/project/ublock 2023-10-22 18:22:27 -04:00
Raymond Hill 1e745c2f4d
Emphasize warning in "My filters"
Related feedback:
f1ce3b2191 (commitcomment-130633291)
2023-10-22 17:52:38 -04:00
Raymond Hill 9bd483bec3
Enable "not permissions" filtering expression in logger
Related feedback:
https://github.com/uBlockOrigin/uBlock-issues/discussions/2714#discussioncomment-6959861
2023-10-22 17:50:45 -04:00
Raymond Hill 9e2c919c24
Import translation work from https://crowdin.com/project/ublock 2023-10-22 15:40:16 -04:00
Raymond Hill a9ff41ae55
Add filter expressions for logger output
Related feedback:
https://github.com/uBlockOrigin/uBlock-issues/discussions/2714#discussioncomment-6959761
2023-10-22 15:33:21 -04:00
Raymond Hill 0b9b5a4802
Enable dev console by default in dev build 2023-10-22 12:33:10 -04:00
Raymond Hill 8c283d4d38
Flush the registered scriptlet cache as needed only
Related commit:
e5b438257f
2023-10-22 12:31:33 -04:00
Raymond Hill f1ce3b2191
Add warning against adding custom filters from untrusted sources
Related discussion:
https://github.com/uBlockOrigin/uBlock-issues/discussions/2895#discussioncomment-7351138
2023-10-22 10:47:52 -04:00
Raymond Hill e33c0f9d9c
Minor refactoring plus other minor changes
Added more evocative error messages to linter.

Made the content of _My filters_ trusted by default in
dev build.
2023-10-22 08:53:01 -04:00
Raymond Hill 64c1f8767c
Add ability to control trusted status of filter lists
Related discussion:
https://github.com/uBlockOrigin/uBlock-issues/discussions/2895

Changes:

The _content of the My filters_ pane is now considered untrusted by
default, and only uBO's own lists are now trusted by default.

It has been observed that too many people will readily copy-paste
filters from random sources. Copy-pasting filters which require trust
represents a security risk to users with no understanding of how the
filters work and their potential abuse.

Using a filter which requires trust in a filter list from an untrusted
source will cause the filter to be invalid, i.e. shown as an error.

A new advanced setting has been added to control which lists are
considered trustworthy: `trustedListPrefixes`, which is a space-
separated list of tokens. Examples of possible values:

- `ublock-`: trust only uBO lists, exclude everything else including
  content of _My filters_ (default value)

- `ublock- user-`: trust uBO lists and content of _My filters_

- `-`: trust no list, essentially disabling all filters requiring
  trust (admins or people who don't trust us may want to use this)

One can also decide to trust lists maintained elsewhere. For example,
for stock AdGuard lists add ` adguard-`. To trust stock EasyList lists,
add ` easylist-`.

To trust a specific regional stock list, look-up its token in
assets.json and add to `trustedListPrefixes`.

The matching is made with String.startsWith(), hence why `ublock-`
matches all uBO's own filter lists.

This also allows to trust imported lists, for example add
` https://filters.adtidy.org/extension/ublock/filters/` to trust all
non-stock AdGuard lists.

Add the complete URL of a given imported list to trust only that one
list.

URLs not starting with `https://` or `file:///` will be rejected,
i.e. `http://example.org` will be ignored.

Invalid URLs are rejected.
2023-10-21 19:29:10 -04:00
Raymond Hill e5b438257f
Ensure scriptlet cache is reset when filtering profile changes
Related issue:
https://github.com/uBlockOrigin/uBlock-issues/issues/2896

TODO: Eventually, distinguish between filtering profile increasing
or decreasing so as to avoid flushing caches when increasing
filtering, which should not affect the scriptlets cache.
2023-10-21 14:25:26 -04:00
Raymond Hill 287f7711aa
Import translation work from https://crowdin.com/project/ublock 2023-10-21 08:19:28 -04:00
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 5bd40b34cd
Support pairing `doc` with `urltransform`
Related feedback:
2e4525fe3c (commitcomment-130203742)
2023-10-18 09:06:28 -04:00
Raymond Hill 74a4772e41
Fix comment 2023-10-18 08:55:09 -04:00
Raymond Hill b98ee0f442
Minor code review 2023-10-17 23:11:06 -04:00
Raymond Hill f34855b859
Do not consider same-creation time to be a stale status
Related commit:
7daf31336a
2023-10-17 12:30:06 -04:00
Raymond Hill 7daf31336a
Ignore assets older than cached version when fetching from CDNs
As discussed with filter list volunteers.

https://github.com/uBlockOrigin/uBlock-discussions/discussions/781#discussioncomment-7283981
2023-10-17 12:08:10 -04:00
Raymond Hill 05ae51beb2
Minor code review of last commit
Related commit:
027c7a4fb5
2023-10-16 18:05:41 -04:00
Raymond Hill 027c7a4fb5
Support quoting scriptlet parameters with backticks
(In addition to in already supported single- and double-quote).

The parsing of (optionally) quoted arguments from an argument
list has been spinned off into a standalone helper in order to
be reused in other parts of the parser eventually.
2023-10-16 17:38:57 -04:00
Raymond Hill c06f5e014f
Prevent redirecting when URL is not transformed
Related commit:
https://github.com/gorhill/uBlock/commit/2e4525fe3c
2023-10-16 11:14:12 -04:00
Raymond Hill 2e4525fe3c
Add new static network filter option: `urltransform`
The `urltransform` option allows to redirect a non-blocked network
request to another URL. There are restrictions on its usage:

- require a trusted source -- thus uBO-maintained lists or user
  filters
- the `urltransform` value must start with a `/`

If at least one of these conditions is not fulfilled, the filter
will be invalid and rejected.

The requirement to start with `/` is to enforce that only the path
part of a URL can be modified, thus ensuring the network request
is redirected to the same scheme and authority (as defined at
https://en.wikipedia.org/wiki/Uniform_Resource_Identifier#Syntax).

Usage example (redirect requests for CSS resources to a non-existing
resource, for demonstration purpose):

    ||iana.org^$css,urltransform=/notfound.css

Name of this option is inspired from DNR API:
https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/declarativeNetRequest/URLTransform

This commit required to bring the concept of "trusted source" to
the static network filtering engine.
2023-10-16 09:47:29 -04:00
Raymond Hill bee64ebd90
Support pane: mark lists as obsolete only when update button is clicked
Lists older than 2 hours were unconditionally marked as obsolete when
opening the _Support_ pane. Those lists will now be marked as obsolete
only when the _Update now_ button in the _Support_ pane is pressed, i.e.
when launching an update cycle.

Related discussion:
https://github.com/uBlockOrigin/uBlock-discussions/discussions/781#discussioncomment-7287323
2023-10-16 07:33:38 -04:00
Raymond Hill c96a673338
Bring `header=` filter option out of experimental status
Related commits:
- bde3164eb4
- 5db8d05975

Reference documentation:
https://github.com/gorhill/uBlock/wiki/Static-filter-syntax#header

Compatible with AdGuard's `header=` option:
https://adguard.com/kb/general/ad-filtering/create-own-filters/#header-modifier

Partially compatible with ABP's `header=` option: Not compatible if
a header value is specified, as ABP requires `=` as separator between
the header name and header value, whereas uBO and AdGuard require `:`
as separator. If no header value is present, the option becomes compatible
with ABP's syntax.
https://gitlab.com/adblockinc/ext/adblockplus/adblockplusui/-/issues/898
2023-10-15 13:17:13 -04:00
Raymond Hill 9a809a8e7c
Fix comment 2023-10-15 11:06:40 -04:00
Raymond Hill 0325dcdcb4
Add ability to update lists through links with specifically crafted URLs
As per discussion with uBO volunteers.

Volunteers offering support for uBO will be able to craft links with
specially formed URLs, which once clicked will cause uBO to automatically
force an update of specified filter lists.

The URL must be crafted as shown in the example below:

https://ublockorigin.github.io/uAssets/update-lists.html?listkeys=ublock-filters,easylist

Where the `listkeys` parameter is a comma-separated list of tokens
corresponding to filter lists. If a token does not match an enabled
filter list, it will be ignored.

The ability to update filter lists through a specially crafted link
is available only on uBO's own support sites:

- https://github.com/uBlockOrigin/
- https://reddit.com/r/uBlockOrigin/
- https://ublockorigin.github.io/

Additionally, a visual cue has been added in the "Filter lists" pane
to easily spot the filter lists which have been recently updated, where
"recently" is currently defined as less than an hour ago.
2023-10-14 13:41:49 -04:00
Raymond Hill f15dff27fe
Minor code review 2023-10-10 13:30:18 -04:00
Raymond Hill 3a5606125d
Import translation work from https://crowdin.com/project/ublock 2023-10-10 10:42:14 -04:00
Raymond Hill 437453233d
Support restoring from `application/json` file
Related issue:
https://github.com/uBlockOrigin/uBlock-issues/issues/2853
2023-10-10 10:16:55 -04:00
Raymond Hill 0a18f75897
Fix dumping of CFE internals when no cosmetic filters present 2023-10-09 11:12:10 -04:00
Raymond Hill 02c7b32bef
Improve `google-ima.js` surrogate
Related issues:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2265
- https://github.com/uBlockOrigin/uAssets/issues/19981
2023-10-07 12:27:03 -04:00
Raymond Hill 4cac9d185b
Reduce race conditions in scriptlet injection on Firefox
This is done by taking advantage through Firefox-specific
contentScripts.register() API:

https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/contentScripts
2023-10-02 08:42:03 -04:00
Raymond Hill b95c90ba7c
Import translation work from https://crowdin.com/project/ublock 2023-09-22 09:36:01 -04:00
Raymond Hill 20d3c6a466
Fix detection of leading combinators
Related feedback:
https://github.com/uBlockOrigin/uBlock-issues/issues/2778#issuecomment-1722488224
2023-09-17 10:37:43 -04:00
Raymond Hill 7ef3408712
Fix regression in `:is()` operator
Related issue:
https://github.com/uBlockOrigin/uBlock-issues/issues/2818
2023-09-16 09:45:46 -04:00
Raymond Hill 313a3121c9
Do not assume set viewport for popup panel when using portrait mode in descktop
Related issue:
https://github.com/uBlockOrigin/uBlock-issues/issues/2814
2023-09-12 20:33:14 -04:00
Raymond Hill 2571660161
Fix removal of `:scope` prefix in `:has()` operator
Related feedback:
https://github.com/uBlockOrigin/uBlock-issues/issues/2778#issuecomment-1705101771
2023-09-11 12:34:53 -04:00
Raymond Hill ba8820fe31
Import translation work from https://crowdin.com/project/ublock 2023-09-08 09:19:26 -04:00
Raymond Hill eccfd3b823
Position reload icon in logger as per feedback
Related feedback:
https://github.com/uBlockOrigin/uBlock-issues/discussions/2782
2023-08-22 19:11:52 -04:00
Raymond Hill 3c7f35ed9c
Import translation work from https://crowdin.com/project/ublock 2023-08-22 10:50:04 -04:00
Raymond Hill 77c3ad2812
Fix bad regression in cosmetic filtering
Related commit:
393fd90f9d
2023-08-20 13:14:36 -04:00
Raymond Hill 55d068aca3
Use Unicode version of hostnames in element picker
Related feedback:
https://www.reddit.com/r/uBlockOrigin/comments/15vfkm6/
2023-08-20 11:27:19 -04:00
Raymond Hill 393fd90f9d
Disallow trailing CSS universal selector unless properly separated
Related discussion:
https://www.reddit.com/r/uBlockOrigin/comments/15tzgud/ads_on_twitterx_again/jwn8bkj/
2023-08-20 10:41:43 -04:00
Raymond Hill 0ad456e905
[mv3] Rename `uBOL-issues` repo to `uBOL-home`
From now on, new uBOL releases will go into uBOL-home repo.
2023-08-19 11:26:33 -04:00
Raymond Hill 857abb380b
[mv3] Add support for converting `^responseheader()` filters to DNR
Additionally, finalize versioning scheme for uBOL. Since most updates
will be simply related to update rulesets, the version will from now
on reflects the date at which the extension package was created:

  year.month.day.minutes

So for example:

  2023.8.19.690
2023-08-19 07:48:14 -04:00