Commit Graph

3893 Commits

Author SHA1 Message Date
Raymond Hill c698a9fcec
Fix overzealous validation of :style() arguments 2022-09-24 12:14:50 -04:00
Raymond Hill d588f46a39
Import translation work from https://crowdin.com/project/ublock 2022-09-24 11:40:42 -04:00
Raymond Hill 966a157d19
[mv3] Add support for procedural cosmetic filtering 2022-09-24 11:33:04 -04:00
Raymond Hill a71b71e4c8
New cosmetic filter parser using CSSTree library
The new parser no longer uses the browser DOM to validate
that a cosmetic filter is valid or not, this is now done
through a JS library, CSSTree.

This means filter list authors will have to be more careful
to ensure that a cosmetic filter is really valid, as there is
no more guarantee that a cosmetic filter which works for a
given browser/version will still work properly on another
browser, or different version of the same browser.

This change has become necessary because of many reasons,
one of them being the flakiness of the previous parser as
exposed by many issues lately:

- https://github.com/uBlockOrigin/uBlock-issues/issues/2262
- https://github.com/uBlockOrigin/uBlock-issues/issues/2228

The new parser introduces breaking changes, there was no way
to do otherwise. Some current procedural cosmetic filters will
be shown as invalid with this change. This occurs because the
CSSTree library gets confused with some syntax which was
previously allowed by the previous parser because it was more
permissive.

Mainly the issue is with the arguments passed to some procedural
cosmetic filters, and these issues can be solved as follow:

Use quotes around the argument. You can use either single or
double-quotes, whichever is most convenient. If your argument
contains a single quote, use double-quotes, and vice versa.

Additionally, try to escape a quote inside an argument using
backslash. THis may work, but if not, use quotes around the
argument.

When the parser encounter quotes around an argument, it will
discard them before trying to process the argument, same with
escaped quotes inside the argument. Examples:

Breakage:

    ...##^script:has-text(toscr')

Fix:

    ...##^script:has-text(toscr\')

Breakage:

    ...##:xpath(//*[contains(text(),"VPN")]):upward(2)

Fix:

    ...##:xpath('//*[contains(text(),"VPN")]'):upward(2)

There are not many filters which break in the default set of
filter lists, so this should be workable for default lists.

Unfortunately those fixes will break the filter for previous
versions of uBO since these to not deal with quoted argument.
In such case, it may be necessary to keep the previous filter,
which will be discarded as broken on newer version of uBO.

THis was a necessary change as the old parser was becoming
more and more flaky after being constantly patched for new
cases arising, The new parser should be far more robust and
stay robist through expanding procedural cosmetic filter
syntax.

Additionally, in the MV3 version, filters are pre-compiled
using a Nodejs script, i.e. outside the browser, so validating
cosmetic filters using a live DOM no longer made sense.

This new parser will have to be tested throughly before stable
release.
2022-09-23 16:03:13 -04:00
Raymond Hill 4bd02c0fb6
[mv3] Inject specific cosmetic filters through scriptlet injection
This solves the following remaining issues regarding specific cosmetic
filtering:
- High rate of false positives in last build
- High number of generated content css files in the package
2022-09-19 08:55:45 -04:00
Raymond Hill 35f4bdd113
Add `ext_ubol` to tokens recognized by the preparser
`ext_ubol` will evaluate to false in uBO, and true in uBO Lite.

Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2268
2022-09-18 11:06:07 -04:00
Raymond Hill 154a71c658
Import translation work from https://crowdin.com/project/ublock 2022-09-18 09:36:13 -04:00
Raymond Hill 5ddd3aaac6
[mv3] More work toward improving declarative css/js injection 2022-09-18 09:31:44 -04:00
q1800 b32de13001
Update about.html (#3874) 2022-09-18 07:15:47 -04:00
q1800 706f3b21d7
Update settings.html (#3875) 2022-09-18 07:15:06 -04:00
Raymond Hill 10406f5f74
Import translation work from https://crowdin.com/project/ublock 2022-09-17 08:35:54 -04:00
Raymond Hill e1b54514cc
[mv3] Add badge reflecting number of injectable content on current site
Additonally, general code review.
2022-09-17 08:26:41 -04:00
Raymond Hill 232c44eeb2
[mv3] Add scriptlet support; improve reliability of cosmetic filtering
First iteration of adding scriptlet support. As with cosmetic
filtering, scriptlet niijection occurs only on sites for which
uBO Lite was granted extended permissions.

At the moment, only three scriptlets are supported:
- abort-current-script
- json-prune
- set-constant

More will be added in the future.
2022-09-16 15:56:35 -04:00
Raymond Hill e7da3beddd
Fix typo in source code of "Filter lists" pane 2022-09-15 14:57:34 -04:00
Raymond Hill 34aab95107
[mv3] Add support for specific cosmetic filtering
Specific plain CSS cosmetic filters are now supported.

Cosmetic filtering will occur only after the user explicitly
grant uBO extended permissions for a given site, so that it
can inject CSS on the site.

A new button in the popup panel allows a user to grant/revoke
extended permissions to/from uBO Lite for the current site.

More capabilities will be carefully added for when extended
permissions are granted on a site, so specific cosmetic
filtering through plain CSS is the first implemented capability.

Generic and procedural cosmetic filtering is not implemented.

The current implementation for plain CSS cosmetic filters is
through declarative content injection, which does not require
the service worker to be alive, the browser takes care to
inject the cosmetic filters.

However declarative CSS injection does not support user
styles, so the injected cosmetic filters are "weak". I consider
this is a browser issue, since user styles are supported by
Chromium, there is just no way in the API to specify user
styles for the injected content.

Also:
- Fixed dark theme issues
- Added Steven Black's hosts file

Keep in mind all this is very experimental and implementation
details in this release may (will) greatly change in the future.
2022-09-15 13:14:08 -04:00
Raymond Hill 43a20f08a8
Import translation work from https://crowdin.com/project/ublock 2022-09-15 12:19:31 -04:00
Raymond Hill 3435e9886e
Import translation work from https://crowdin.com/project/ublock 2022-09-13 17:58:12 -04:00
Raymond Hill e31637af78
[mv3] Add ability to enable/disable filter lists 2022-09-13 17:44:24 -04:00
Raymond Hill d11a3f2fa3
Fix broken :not() operator when forcing parsing as procedural
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2262
2022-09-13 16:15:22 -04:00
Raymond Hill 887a87d9ca
Add support to report/filter SVG image elements
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2260
2022-09-11 12:20:01 -04:00
Raymond Hill 067e128163
Patch google-ima shim script for proper integration into uBO
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2158

Additionally, added firing of CONTENT_RESUME_REQUESTED event in
start() method.
2022-09-11 11:03:47 -04:00
Raymond Hill b6b6e49d57
Add original Firefox-authored google-ima shim script
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2158
2022-09-11 10:54:54 -04:00
Raymond Hill 9ce9588737
Import translation work from https://crowdin.com/project/ublock 2022-09-11 09:18:20 -04:00
Raymond Hill 257100e921
Add missing i18n attribute 2022-09-11 09:09:31 -04:00
Emilio Cobos Álvarez 4044aa182a
element-picker: Declare we support both light and dark color-schemes. (#3872)
This fixes https://github.com/uBlockOrigin/uBlock-issues/issues/2240 and
should get the desired behavior regardless of browser.

Delay showing the iframe until load to prevent flashing a white
background on the initial about:blank.
2022-09-11 07:34:29 -04:00
Raymond Hill 453fb1eb5e
Fix wording 2022-09-10 21:12:40 -04:00
Raymond Hill 4314764c48
Add missing translatable string
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1681
2022-09-10 21:05:09 -04:00
Raymond Hill 0d80a1132d
Fix typo in CSS 2022-09-10 16:08:05 -04:00
Raymond Hill 5716c1c6a0
Add two more strings to translate
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1681
2022-09-10 14:16:23 -04:00
Raymond Hill ac89b4e0f7
Import translation work from https://crowdin.com/project/ublock 2022-09-10 14:15:08 -04:00
Raymond Hill 3029c78a55
Redesign document-blocked page
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1681

The redesign is inspired by Brave's corresponding document-blocked
page.
2022-09-10 14:11:23 -04:00
Raymond Hill 60d1206215
Make popup panel reflect state of the actual blocked page
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1954
2022-09-10 11:55:19 -04:00
Raymond Hill 707609dc86
Do not set color-scheme CSS style in epicker for Firefox 106+
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2240
2022-09-10 10:07:16 -04:00
Raymond Hill f806438de6
Unescaped escaped commas in regex-based removeparam values
Related discussion:
- https://github.com/uBlockOrigin/uAssets/discussions/14683#discussioncomment-3559284
2022-09-08 19:37:24 -04:00
Raymond Hill 1258414f37
Report ruleset stats in popup panel 2022-09-08 10:04:08 -04:00
Raymond Hill 224410a6f5
Add per-site on/off switch to mv3 experimental version 2022-09-07 10:15:36 -04:00
Raymond Hill a559f5f271
Add experimental mv3 version
This create a separate Chromium extension, named
"uBO Minus (MV3)".

This experimental mv3 version supports only the blocking of
network requests through the declarativeNetRequest API, so as
to abide by the stated MV3 philosophy of not requiring broad
"read/modify data" permission. Accordingly, the extension
should not trigger the warning at installation time:

    Read and change all your data on all websites

The consequences of being permission-less are the following:

- No cosmetic filtering (##)
- No scriptlet injection (##+js)
- No redirect= filters
- No csp= filters
- No removeparam= filters

At this point there is no popup panel or options pages.

The default filterset correspond to the default filterset of
uBO proper:

Listset for 'default':
  https://ublockorigin.github.io/uAssets/filters/badware.txt
  https://ublockorigin.github.io/uAssets/filters/filters.txt
  https://ublockorigin.github.io/uAssets/filters/filters-2020.txt
  https://ublockorigin.github.io/uAssets/filters/filters-2021.txt
  https://ublockorigin.github.io/uAssets/filters/filters-2022.txt
  https://ublockorigin.github.io/uAssets/filters/privacy.txt
  https://ublockorigin.github.io/uAssets/filters/quick-fixes.txt
  https://ublockorigin.github.io/uAssets/filters/resource-abuse.txt
  https://ublockorigin.github.io/uAssets/filters/unbreak.txt
  https://easylist.to/easylist/easylist.txt
  https://easylist.to/easylist/easyprivacy.txt
  https://malware-filter.gitlab.io/malware-filter/urlhaus-filter-online.txt
  https://pgl.yoyo.org/adservers/serverlist.php?hostformat=hosts&showintro=1&mimetype=plaintext

The result of the conversion of the filters in all these
filter lists is as follow:

Ruleset size for 'default': 22245
  Good: 21408
  Maybe good (regexes): 127
  redirect-rule= (discarded): 458
  csp= (discarded): 85
  removeparams= (discarded): 22
  Unsupported: 145

The fact that the number of DNR rules are far lower than the
number of network filters reported in uBO comes from the fact
that lists-to-rulesets converter does its best to coallesce
filters into minimal set of rules. Notably, the DNR's
requestDomains condition property allows to create a single
DNR rule out of all pure hostname-based filters.

Regex-based rules are dynamically added at launch time since
they must be validated as valid DNR regexes through
isRegexSupported() API call.

At this point I consider being permission-less the limiting
factor: if broad "read/modify data" permission is to be used,
than there is not much point for an MV3 version over MV2, just
use the MV2 version if you want to benefit all the features
which can't be implemented without broad "read/modify data"
permission.

To locally build the MV3 extension:

    make mv3

Then load the resulting extension directory in the browser
using the "Load unpacked" button.

From now on there will be a uBlock0.mv3.zip package available
in each release.
2022-09-06 13:47:52 -04:00
Raymond Hill bcede6f938
Fix validating argument for :not() as procedural
Related feedback:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2228#issuecomment-1234248802
2022-09-01 09:42:48 -04:00
Raymond Hill 79451e5899
Force prodecural cosmetic filtering when explicitly stated
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2228

Using `#?#` (instead of `##` for a procedural cosmetic filter will
prevent uBO from trying to convert the filter into a declarative
one.
2022-08-31 13:57:39 -04:00
Raymond Hill 8f39a457b8
Fallback procedural :has() operator when argument is not a valid plain CSS selector
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2228
2022-08-23 16:36:22 -04:00
Raymond Hill 04114942aa
Add missing method to shim script
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2225
2022-08-21 12:54:02 -04:00
Raymond Hill a24bc50e40
Fix deprecated matches-css-after/matches-css-before 2022-08-18 12:04:56 -04:00
Raymond Hill 7bc0b5d2bd
Extend matches-css() to support any pseudo-element
This commit deprecates matches-css-before() and matches-css-after(): these
should no longer be used once 1.45.0 is published and widespread. The
deprecated syntax will eventually be removed in some future.

The syntax of procedural operator matches-css() has been extended to also
be able to target pesudo elements. Examples:

Same as before:

    example.com##p:matches-css(opacity: 0.5)

This is the new way to target an `::after` pseudo-element:

    example.com##p:matches-css(after, content: Ads)

This is the new way to target a `::before` pseudo-element:

    example.com##p:matches-css(before, content: Ads)

The new syntax also means any valid pseudo-element can now be used as
a target:

    example.com##p:matches-css(first-letter, opacity: 0.5)

If the first argument does not match the pattern "property name: value",
then it will be deemed a pseudo-element to target, and the second argument
will be the "property name: value".

Related issue:
- https://github.com/AdguardTeam/ExtendedCss/issues/150
2022-08-18 11:28:44 -04:00
Raymond Hill e54025d6bf
Import translation work from https://crowdin.com/project/ublock 2022-08-16 09:46:02 -04:00
Raymond Hill c521479ef9
Add 0.5s mp3 redirectable resource
Command used to generate 0.5s mp3 file:

ffmpeg -ar 48000 -t 0.5 -f s16le -acodec pcm_s16le -ac 2 -i /dev/zero -acodec libmp3lame -aq 4 noop-0.5s.mp3

Related filter issue:
- https://github.com/uBlockOrigin/uAssets/issues/14231
2022-08-14 13:06:00 -04:00
Raymond Hill cd50f76e74
Fix static filtering parser's validation of selectors/styles
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2170#issuecomment-1207921464
2022-08-08 12:04:17 -04:00
Raymond Hill e62604f889
Add queue-related initialization code to AMZN shim script
This would render obsolete the AMZN-related exception at the
following URL:

https://play.mylifetime.com/shows/married-at-first-sight/season-15/episode-1

And possibly lower the likelihood of breakage on other sites.
2022-08-05 11:26:23 -04:00
Raymond Hill b01d57ab63
Fix dark theme issue in DOM inspector
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2196
2022-08-04 10:52:09 -04:00
Raymond Hill e2043b6554
Fix regression in handling of procedural cosmetic filters
Related commit:
- 91caed32d3

Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2185#issuecomment-1193862432
2022-07-25 10:10:44 -04:00
Raymond Hill 91caed32d3
Improve conversion of procedural cosmetic filters into CSS rules
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2185#issuecomment-1193164728
2022-07-24 11:41:08 -04:00