1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-11-01 16:33:06 +01:00
Commit Graph

75 Commits

Author SHA1 Message Date
Raymond Hill
c5724c1cce
Enable path for native has() selector in Firefox
Reference:
https://bugzilla.mozilla.org/show_bug.cgi?id=1858743
2023-11-20 19:38:18 -05:00
Raymond Hill
eb235404bd
Use 'wasm-unsafe-eval' instead of deprecated 'wasm-eval'
Reference:
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/script-src#unsafe_webassembly_execution
2023-08-18 10:01:08 -04:00
Raymond Hill
2a6c1d30b4
Fix regression in vAPI.warSecret guard code
Related commit:
https://github.com/gorhill/uBlock/commit/bf591d93fb
2023-08-14 13:39:27 -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
d5dec1d3c4
Return string when storage.sync.get() promise fails
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2660
2023-05-16 19:26:46 -04:00
Raymond Hill
578fc21bd9
Report injected scriptlets in troubleshooting information
This requires to rewrite portions of scriptlet filtering
code.
2023-05-09 12:44:14 -04:00
Raymond Hill
348f75af7f
Reverse usage of browser.alarms
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2604

Related commit:
- bec6cad2c0
2023-04-26 08:00:13 -04:00
Raymond Hill
1ffdb7d948
Various minor code review 2023-04-25 21:15:11 -04:00
Raymond Hill
98d4d24f9b
Mind rejected promises from vAPI.storage API
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2604
2023-04-22 19:29:54 -04:00
Raymond Hill
c97d0ab062
Forcefully clear unprocessed-request status after a minute
Related feedback:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2589#issuecomment-1507084473
2023-04-13 11:41:52 -04:00
Raymond Hill
0575567d2a
Time when main listener was installed is enough 2023-04-12 18:24:30 -04:00
Raymond Hill
86477dd4e5
Move faster test first 2023-04-12 18:08:11 -04:00
Raymond Hill
bacf5d1661
Better integrate suspend-network with unprocessed-request
Also added additional safeguard against sticky unprocessed-request
status: all unprocessed-request statuses will be cleared after a
minute elapsed following intialization. The idea is that if the
user hasn't care to force a reload of the page, then it's assumed
to be by choice and uBO should stop informing about the status.
2023-04-12 16:10:00 -04:00
Raymond Hill
a1619a118d
Minor code review 2023-04-12 12:13:31 -04:00
Raymond Hill
b47ecb6bfa
Do not clobber rightful onBeforeSuspendableRequest listener 2023-04-12 11:22:45 -04:00
Raymond Hill
bc54179edd
More aggressively clear the unprocessed-request status
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2589
2023-04-12 10:55:00 -04:00
Raymond Hill
f0eadae3ba
Clear unprocessed status of removed tabs 2023-04-11 22:38:43 -04:00
Raymond Hill
8083e06b30
Revert 09b3695205 (re. browser.alarms)
Relates issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2591

THe issue was simply that I had forgotten to add the `alarms`
permission to the manifest.
2023-04-11 18:06:57 -04:00
Raymond Hill
09b3695205
Provide fallback API for platforms not supporting alarms API
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2591
2023-04-11 08:40:18 -04:00
Raymond Hill
bf5f343548
Replace toolbar icon tooltip with message section in panel
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2585

Related feedback:
- https://www.reddit.com/r/uBlockOrigin/comments/126rn4f/yellow_toolbar_icon_exclamation_mark_badge/jfns0pc/
2023-04-10 17:10:00 -04:00
Raymond Hill
63d0f124ba
Replace requestIdleCallback() with new vAPI.defer utility
Related commit:
- 91f9795023
2023-04-10 10:10:19 -04:00
Raymond Hill
3530b9dc89
Add informative tooltip re. unprocessed requests at launch
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2585
2023-04-09 14:02:01 -04:00
Raymond Hill
91f9795023
Wrap usage of setTimeout in helper for background + auxiliary pages
This commit centralizes usage of setTimeout()/clearTimeout() in the
source code at one single location.
2023-04-09 13:38:16 -04:00
Raymond Hill
bec6cad2c0
Start using browser.alarms instead of setTimeout() where applicable
Related documentation:
https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Background_scripts#convert_to_non-persistent
2023-04-07 20:24:20 -04:00
Raymond Hill
6e8aeae283
Flush memory cache at key filtering profile changes
To reduce the need for hard reload after changes in filters,
rules.
2023-04-03 10:19:06 -04:00
Raymond Hill
0b09155268
Clear unprocessed requests status on webNavigation reload event
Related feedback:
- https://github.com/uBlockOrigin/uBlock-issues/discussions/2564
2023-03-30 17:12:45 -04:00
Raymond Hill
1835e90125
Avoid using ! toolbar icon badge when inconsequential
uBO will now verify that at least one unprocessed network requests
at launch should have been blocked in order to warn users of
unprocessed network requests through the `!` toolbar icon badge.

For example, with default filter lists, there is nothing to block
on `wikipedia.org`, and hence in this case it's not useful to
present the user with the `!` badge.

Therefore uBO will not show the badge *only* when at least one
unprocessed network requests should have been blocked had uBO been
ready when it was fired by the browser.

Related commit:
- https://github.com/gorhill/uBlock/commit/769b8da664be
2023-03-30 12:30:44 -04:00
Raymond Hill
10f9559a52
Add 64px toolbar icon for 4K displays
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2477
2023-03-27 12:59:39 -04:00
Raymond Hill
2f42cf61ab
Properly handle potential exception from webext API
Related feedback:
- https://github.com/uBlockOrigin/uAssets/discussions/16939#discussioncomment-5356808
2023-03-19 07:25:06 -04:00
Raymond Hill
60827c603d
Cached managed storage content for faster readiness
Related issue:
- https://github.com/uBlockOrigin/uAssets/discussions/16939
2023-03-18 17:23:13 -04:00
Raymond Hill
bb462e6e5d
Actual icon color is #FFCC00, not #FC0 2023-03-18 12:27:40 -04:00
Raymond Hill
a72c068bcc
Make badge color consistent with filtering status
Related commit:
- 32508620a2
2023-03-18 12:16:20 -04:00
Raymond Hill
32508620a2
Emphasize broken filtering at launch on toolbar icon badge
Related feedback:
- 769b8da664 (commitcomment-104695781)

The incomplete filtering status of a given tab at browser launch
will be carried over visually as a yellowish `!` badge until the
web page in the tab is force reloaded, navigated away, or closed.

The purpose is to make it obvious to end users that a web page
has not been filtered properly and to avoid issue reports
related to this.

It is expected that Firefox should never be affected by cases of
yellowish badge -- that is unless the setting "Suspend network
activity [...]" has been disabled, in which case the new behavior
will also be useful to those who disabled the setting.
2023-03-18 11:35:06 -04:00
Raymond Hill
769b8da664
Finalize "unreadiness" toolbar icon
- Yellow uBO toolbar icon: uBO not ready

- Yellow uBO toolbar icon + `!` badge: network requests went
  through while uBO is not ready
2023-03-16 07:13:27 -04:00
Raymond Hill
39cac612c2
Use the warning toolbar icon only if unprocessed requests
Related discussion:
- https://github.com/uBlockOrigin/uAssets/discussions/16939

Related commit:
- 0c9576d3e6
2023-03-15 21:13:28 -04:00
Raymond Hill
f9b03ebeac
Report unprocessed network request count in troubleshooting info
Related discussion:
- https://github.com/uBlockOrigin/uAssets/discussions/16939
2023-03-08 09:36:09 -05:00
Raymond Hill
0c9576d3e6
Show a distinct toolbar icon until filtering engines are fully initialized
Related discussion:
- https://github.com/uBlockOrigin/uAssets/discussions/16939

Until uBO's filtering engines are properly initialized, there will
be a distinct toolbar icon to help users understand that uBO may
not be fully initialized when a webpage is loaded -- often the
cause of improper filtering of trackers/ads at browser launch.
2023-03-07 16:02:09 -05:00
Raymond Hill
454a03a98f
Use block scope to isolate context 2023-02-24 18:02:28 -05:00
Raymond Hill
e2c3917ecd
Unconditionally set label of toolbar icon
Related feedback:
- https://github.com/uBlockOrigin/uBlock-issues/discussions/2409
2022-12-15 10:04:03 -05:00
Raymond Hill
a91781a495
Rewrite logger's "exceptor" feature
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1861

The "exceptor" feature has been rewritten, with the following
changes as a result:

- The excepted filters cease to exist when closing the logger
- It's now possible to temporary except network filters

When toggling on/off a temporary exception, filter lists are now
fully reloaded. This simplified managing temporary exceptions, and
made it easy to implement temporary exception for network filters,
but this also means there might be a perceptible delay when
adding/removing temporary exceptions. At this point I consider
this an acceptable side-effect just to bring the ability to easily
create temporary exception for network filters, while this
simplified the existing temporary exception code throughout.
2022-12-14 16:04:45 -05:00
Raymond Hill
58e60d6d96
Fix various regressions in latest dev build
Related issues:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2404
- https://github.com/uBlockOrigin/uBlock-issues/issues/2400#issuecomment-1346050327
2022-12-12 14:02:57 -05:00
Raymond Hill
0bfffb80c4
Fix spurious warning
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2243
2022-10-05 07:28:01 -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
e31637af78
[mv3] Add ability to enable/disable filter lists 2022-09-13 17:44:24 -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
0c9ab84846
Fix redundant calls to extract image data
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2243#issuecomment-1236194011
2022-09-04 10:40:26 -04:00
Raymond Hill
127ea05a9e
Replace responsive with intab for better remdering og panel in a tab
Related feedback:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2116#issuecomment-1143634719
2022-06-04 11:12:45 -04:00
Raymond Hill
1c090f0fae
Use string template 2022-06-03 12:27:51 -04:00
u-RraaLL
614b8328e9
Update popup url
Fix broken functionality caused by the removal of the classic popup.
2022-05-21 09:42:08 +02:00
Raymond Hill
60072e7996
Minor code review
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1992
2022-02-18 06:52:34 -05:00