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

1764 Commits

Author SHA1 Message Date
Raymond Hill
1ad7410077
[mv3] Fine tune various portions of code 2023-06-06 13:42:22 -04:00
Raymond Hill
f282b43550
[mv3] Move hostname label to top of popup panel
Related commit in uBO:
- b8cfa382e8

Additionally, render internationalized domain names in pretty Unicode
instead of ugly punycode.
2023-06-06 09:04:21 -04:00
Raymond Hill
5874312b35
[mv3] Avoid String.replace() to safely replace templates
String.replace() has side effects which are unwelcomed when
replacing template scriplets with code.
2023-06-05 20:17:50 -04:00
Raymond Hill
7e712246a9
[mv3] Let the scriplet sort out targeted sites when too many targets
This is too avoid `matches` property with too many hostnames at
registerContentScripts() time. Threshold has been arbitrarily
set at 100.
2023-06-05 12:14:37 -04:00
Raymond Hill
6d9bef28ff
[mv3] Fix issue with updateContentScripts API and other fixes
Avoid using updateContentScripts() as it suffers from an unexpected
behavior, causing injected content scripts to lose proper order
at injection time. The order in which content scripts are injected
is key for uBOL content scripts. Potential out of order injection
was causing cosmetic filtering to be broken.

Use actual storage API to persist data across service worker
wake-ups and browser launches. uBOL was trying to avoid using
storage API, at the cost of somewhat hacky code (using DNR API
to persist settings).

Make use of session storage if available, to speed up
initialization of waking up the service worker (which at this
point is necessary to properly implement cosmetic filtering).
2023-06-05 09:15:59 -04:00
Raymond Hill
6dbbb95b04
[mv3] Mitigation: Inject CSS user styles to enforce cosmetic filtering
Related issues:
- https://github.com/uBlockOrigin/uBOL-issues/issues/5#issuecomment-1575425913
- https://github.com/w3c/webextensions/issues/403

Currently, there is no other way to inject CSS user styles than to
wake up the service worker, so that it can inject the CSS styles
itself using the `scripting.insertCSS()` method.

If ever the MV3 API supports injecting CSS user styles directly
from a content script, uBOL will be back to be fully declarative.

At this point the service worker is very lightweight since the
filtering is completely  declarative, so this is not too much of
an issue performance-wise except for the fact that waking up the
service worker for the sole purpose of injecting CSS user styles
and nothing else introduces a pointless overhead.

Hopefully the MV3 API will mature to address such inefficiency.
2023-06-04 11:32:55 -04:00
Raymond Hill
72726a4759
[mv3] Refactor content scripts related to specific cosmetic filtering
Specifically, avoid long list of hostnames for the `matches`
property[1] when registering the content scripts, as this was causing
whole browser freeze for long seconds in Chromium-based browsers
(reason unknown).

The content scripts themselves will sort out which cosmetic filters to
apply on which websites.

This change makes it now possible to support annoyances-related lists,
and thus two lists have been added:
- EasyList -- Annoyances
- EasyList -- Cookies

Related issue:
- https://github.com/uBlockOrigin/uBOL-issues/issues/5

These annoyances-related lists contains many thousands of specific
cosmetic filters and as a result, before the above change this was
causing long seconds of whole browser freeze when simply modifying
the blocking mode of a specific site via the slider in the popup
panel.

It is now virtually instantaneous, at the cost of injecting larger
cosmetic filtering-related content scripts (which typically should
be garbage-collected within single-digit milliseconds).

Also, added support for entity-based cosmetic filters. (They were
previously discarded).

---

[1] https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/scripting/RegisteredContentScript
2023-06-03 22:08:42 -04:00
Raymond Hill
b163097399
[mv3] Extend scriplet filtering support to all scriptlets
Source code of scriplets is now fetched directly from uBO
project, so there is no longer the need to keep duplicate
versions of scriplet code.

All scriplet filters are now supported.
2023-06-02 17:04:15 -04:00
Raymond Hill
ea15cef524
[mv3] Also log salvaged rules using entity-based domains
Some filters with entity-based domain option can be salvaged
when there are non-entity-based domain option, but since we are
throwing away the entity-based entries, we are only partially
converting to DNR. This commit will log a warning about this
in log.txt. Before this commit, only non-salvageable filters
were logged.
2023-05-26 13:18:20 -04:00
Raymond Hill
9134c11cf8
Fix https://github.com/uBlockOrigin/uBlock-issues/issues/2668
Use document.append() only when there are no elements in
the DOM, as a document instance can't have more than one
direct child.
2023-05-23 21:49:42 -04:00
Raymond Hill
1a863a877d
Support injecting scriptlet in MAIN or ISOLATED world
This reflects the _world_ of the MV3 scripting API:
https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/scripting/ExecutionWorld

MAIN: page's world
ISOLATED: extension's content script world

Some scriptlets are best executed in either world, so this
commit allows to pick in which world a scriptlet should execute
(default to MAIN).

For instance, the new sed.js scriptlet will now execute in
the ISOLATED world.
2023-05-22 20:19:00 -04:00
Raymond Hill
56f67631d6
Fix regression in handling mode changes 2023-05-20 17:21:14 -04:00
Raymond Hill
eb2d6d1374
Bring scriptlets up to date 2023-05-19 15:36:01 -04:00
Raymond Hill
13a4f869d2
Fix sticky blocking mode
Related issue:
- https://github.com/uBlockOrigin/uBOL-issues/issues/42

Take into account that subdomains inherit the blocking mode
of their parent domain when toggling blocking mode of specific
hostnames.
2023-05-19 15:08:23 -04:00
Raymond Hill
07845196b7
Import translation work from https://crowdin.com/project/ublock 2023-05-17 10:25:27 -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
d27b3471e1
Import translation work from https://crowdin.com/project/ublock 2023-05-16 12:21:59 -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
ad8b7b2f12
Fix filter list paths 2023-05-07 09:19:01 -04:00
Raymond Hill
7f9c4ce45f
Import translation work from https://crowdin.com/project/ublock 2023-05-06 17:26:19 -04:00
Raymond Hill
bedb733e67
Fix thunderbird manifest 2023-04-27 21:50:44 -04:00
Raymond Hill
ad969ec153
Import translation work from https://crowdin.com/project/ublock 2023-04-27 08:52:32 -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
ae474aae40
Remove languages with no translations, no activity 2023-04-25 14:21:46 -04:00
Raymond Hill
bf53737db4
Import translation work from https://crowdin.com/project/ublock 2023-04-24 09:47:59 -04:00
Raymond Hill
a2725cb987
Import translation work from https://crowdin.com/project/ublock 2023-04-22 19:34:26 -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
8616b395b2
Internally support no-filtering as default mode
Even though this cannot be set through the user interface.
2023-04-21 19:24:43 -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
a5f735b585
Fix mv3 builds 2023-04-11 09:35:31 -04:00
Raymond Hill
47287caf1f
Use valid Gecko version 2023-04-11 08:42:28 -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
c5d62d9ae7
Import translation work from https://crowdin.com/project/ublock 2023-04-09 14:00:39 -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
b408b9314c
Use more reliable way to check browser environment 2023-04-07 13:00:01 -04:00
Raymond Hill
cbfd2ad942
Create a MVP version of uBOLite for Firefox
What does not work at the time of commit:

Cosmetic filtering does not work:

The content scripts responsible for cosmetic filtering fail when
trying to inject the stylesheets through document.adoptedStyleSheets,
with the following error message:

  XrayWrapper denied access to property Symbol.iterator
  (reason: object is not safely Xrayable).
  See https://developer.mozilla.org/en-US/docs/Xray_vision for more
  information. ... css-declarative.js:106:8

A possible solution is to inject those content scripts in the
MAIN world. However Firefox scripting API does not support MAIN
world injection at the moment.

Scriptlet-filtering does not work:

Because scriptlet code needs to be injected in the MAIN world,
and this is currently not supported by Firefox's scripting API,
see https://bugzilla.mozilla.org/show_bug.cgi?id=1736575

There is no count badge on the toolbar icon in Firefox, as it
currently does not support the `DNR.setExtensionActionOptions`
method.

Other than the above issues, it does appear uBO is blocking
properly with no error reported in the dev console.

The adoptedStyleSheets issue though is worrisome, as the
cosmetic filtering content scripts were designed with ISOLATED
world injection in mind. Being forced to inject in MAIN world
(when available) make things a bit more complicated as uBO
has to ensure it's global variables do not leak into the page.
2023-04-07 10:19:43 -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