Commit Graph

1959 Commits

Author SHA1 Message Date
Raymond Hill 38b325ecce
Raise the limit for detection of stale content scripts 2024-03-17 13:03:19 -04:00
Raymond Hill 3f7374c1f1
Mind that `tabs.sendMessage` can throw 2024-03-17 09:34:05 -04:00
Raymond Hill 65b6753c69
Simpler to use an extra property than to use a new assets.json 2024-03-14 10:20:25 -04:00
Raymond Hill 52b46eb98b
Add procedural operator `:shadow()` -- status is experimental
For internal use by filter list maintainers, do not open issues
about this. Left undocumented on purpose.

This new procedural operator allows to target elements in the
shadow root of an element.

subject:shadow(arg)

- Description: Look-up matching elements inside the shadow root (if
  present) of _subject_.
- Chainable: Yes
- _subject_: Can be a plain or procedural selector.
- _arg_: A plain or a procedural selector for the elements to target
  inside the shadowroot.

Example:

..##body > div:not([class]):shadow(div[style]):has(:shadow([data-i18n^="#ad"]))
2024-03-13 14:28:53 -04:00
Raymond Hill c8762945d9
Fix failure to create popup logger window sometimes
Related issue:
https://github.com/uBlockOrigin/uBlock-issues/issues/2249
2024-03-13 10:01:33 -04:00
Raymond Hill 710d8c6494
Import translation work from https://crowdin.com/project/ublock 2024-03-12 10:08:22 -04:00
Raymond Hill 2c9ab8ee04
Fix the salvaging of rule ids 2024-03-11 22:22:57 -04:00
Raymond Hill 633135745f
Need new `assets.son` file for next release
Related issue:
https://github.com/uBlockOrigin/uBlock-issues/issues/3154
2024-03-11 18:41:18 -04:00
Raymond Hill 0332bf163c
Import translation work from https://crowdin.com/project/ublock 2024-03-11 13:29:30 -04:00
Raymond Hill d5c359d411
Import translation work from https://crowdin.com/project/ublock 2024-03-07 13:09:24 -05:00
Raymond Hill 8533fa74ee
[mv3] Use EasyList lists for "Annoyances" section 2024-03-07 09:14:30 -05:00
Raymond Hill 02966afb8c
[mv3] Do not pollute browser console in stable release versions 2024-03-06 12:46:12 -05:00
Raymond Hill f18d62ee4c
Import translation work from https://crowdin.com/project/ublock 2024-03-05 08:11:39 -05:00
Raymond Hill c7a9bcb7b2
Import translation work from https://crowdin.com/project/ublock 2024-03-04 11:38:55 -05:00
Raymond Hill 0a72745f9c
Import translation work from https://crowdin.com/project/ublock 2024-03-03 20:28:07 -05:00
Raymond Hill aac88ac766
Import translation work from https://crowdin.com/project/ublock 2024-03-03 14:30:30 -05:00
Raymond Hill c2c80be897
Forgot Chromium's `alarms` API is not promisified... 2024-02-29 20:29:36 -05:00
Raymond Hill d8544dc047
Forgot to declarare "alarms" permmission in manifest for Chromium
Related commit:
https://github.com/gorhill/uBlock/commit/059e4e5e28
2024-02-29 13:18:33 -05:00
Raymond Hill 059e4e5e28
Imrpove saving request stats for non-persistent background page
Related issue:
https://github.com/uBlockOrigin/uBlock-issues/issues/2969

Related previous commit:
https://github.com/gorhill/uBlock/commit/5a338b7210

The save-to-storage period is back to being around ~4 minutes, but
now browser.storage.session API is used to keep track of request
stats should the extension be suspended before the period elapse.
2024-02-29 11:43:51 -05:00
Raymond Hill 09bba3199e
Import translation work from https://crowdin.com/project/ublock 2024-02-29 09:48:01 -05:00
Raymond Hill 9862446b10
Various fine tuning code of recent commits 2024-02-28 13:32:24 -05:00
Raymond Hill 79ea85dbc4
More fine tuning of cache storage-related code 2024-02-27 21:47:06 -05:00
Raymond Hill 086766a924
Redesign cache storage
In uBO, the "cache storage" is used to save resources which can
be safely discarded, though at the cost of having to fetch or
recompute them again.

Extension storage (browser.storage.local) is now always used as
cache storage backend. This has always been the default for
Chromium-based browsers.

For Firefox-based browsers, IndexedDB was used as backend for
cache storage, with fallback to extension storage when using
Firefox in private mode by default.

Extension storage is reliable since it works in all contexts,
though it may not be the most performant one.

To speed-up loading of resources from extension storage, uBO will
now make use of Cache API storage, which will mirror content of
key assets saved to extension storage. Typically loading resources
from Cache API is faster than loading the same resources from
the extension storage.

Only resources which must be loaded in memory as fast as possible
will make use of the Cache API storage layered on top of the
extension storage.

Compiled filter lists and memory snapshot of filtering engines
(aka "selfies") will be mirrored to the Cache API storage, since
these must be loaded into memory as fast as possible, and reloading
filter lists from their compiled counterpart is a common
operation.

This new design makes it now seamless to work in permanent private
mode for Firefox-based browsers, since extension storage now
always contains cache-related assets.

Support for IndexedDB is removed for the time being, except to
support migration of cached assets the first time uBO runs with
the new cache storage design.

In order to easily support all choices of storage, a new serializer
has been introduced, which is capable of serializing/deserializing
structure-cloneable data to/from a JS string.

Because of this new serializer, JS data structures can be stored
directly from their native representation, and deserialized
directly to their native representation from uBO's point of view,
since the serialization occurs (if needed) only at the storage
interface level.

This new serializer simplifies many code paths where data
structures such as Set, Map, TypedArray, RegExp, etc. had to be
converted in a disparate manner to be able to persist them to
extension storage.

The new serializer supports workers and LZ4 compression. These
can be configured through advanced settings.

With this new layered design, it's possible to introduce more
storage layers if measured as beneficial (i.e. maybe
browser.storage.session)

References:
- https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/storage/local
- https://developer.mozilla.org/en-US/docs/Web/API/Cache
- https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm
2024-02-26 16:50:11 -05:00
Raymond Hill fcc77e7c92
[mv3] Add ability to manually add filters to a ruleset 2024-02-25 20:39:21 -05:00
Raymond Hill 4af57e3e60
Import translation work from https://crowdin.com/project/ublock 2024-02-17 09:34:41 -05:00
Raymond Hill 7e00046b8e
[mv3] Salvage rule ids for all rulesets 2024-02-15 08:02:46 -05:00
Raymond Hill 8d47eac6e6
[mv3] Indent rulesets with fewer rules 2024-02-14 15:48:59 -05:00
Raymond Hill f2d7413a42
[mv3] Reuse rule ids across release where possible
This is to reduce the diff size of rulesets in new
releases. Beside smaller diff size, this also makes it
easier to investigate rule changes across releases.
2024-02-14 14:27:36 -05:00
Raymond Hill a7786a0a32
Import translation work from https://crowdin.com/project/ublock 2024-02-13 15:36:10 -05:00
Raymond Hill 0e8ff10e92
[mv3] Mind service workers for sites in "no filtering" mode
Related issue:
https://github.com/uBlockOrigin/uBOL-home/issues/114
2024-01-31 09:59:45 -05:00
Raymond Hill be1f938c17
[mv3] Adjust as per changes in uBO base 2024-01-26 14:51:50 -05:00
Raymond Hill c11db790ff
Import translation work from https://crowdin.com/project/ublock 2024-01-25 12:49:32 -05:00
Raymond Hill 869a653fdf
Output scriptlet logging information to the logger
This commit brings the following changes to the logger:

All logging output generated by injected scriptlets are now sent to
the logger, the developer console will no longer be used to log
scriptlet logging information.

When the logger is not opened, the scriplets will not output any
logging information.

The goal with this new approach is to allow filter authors to
more easily assess the working of scriptlets without having to
go through scriptlet parameters to enable logging.

Consequently all the previous ways to tell scriptlets to log
information are now obsolete: if the logger is opened, the
scriptlets will log information to the logger.

Another benefit of this approach is that the dev tools do not
need to be open to obtain scriptlets logging information.

Accordingly, new filter expressions have been added to the logger:
"info" and "error". Selecting the "scriptlet" expression will also
keep the logging information from scriptlets.

A new button has been added to the logger (not yet i18n-ed): a
"volume" icon, which allows to enable verbose mode. When verbose
mode is enabled, the scriptlets may choose to output more
information regarding their inner working.

The entries in the logger will automatically expand on mouse hover.
This allows to scroll through entries which text does not fit into
a single row.

Clicking anywhere on an entry in the logger will open the detailed
view when applicable.

Generic information/errors will now be rendered regardless of which
tab is currently selected in the logger (similar to how tabless
entries are already being rendered).
2024-01-25 12:20:38 -05:00
Raymond Hill f1889b02ee
[mv3] Fix conversion of `:xpath` procedural filters
Procedural filters with `:xpath` operator were silently rejected
at conversion time because the parser was failing to evaluate the
xpath expression due to the absence of a `document` object in
nodejs.

If `document` object is not present, the parser will assume the
xpath expression is valid.
2024-01-22 10:57:48 -05:00
Raymond Hill 3d576603c4
[mv3] `uritransform` cannot be converted to DNR 2024-01-21 14:32:14 -05:00
Raymond Hill 101cef44d2
Import translation work from https://crowdin.com/project/ublock 2024-01-16 08:49:52 -05:00
Raymond Hill a605f13e63
Import translation work from https://crowdin.com/project/ublock 2024-01-14 09:58:34 -05:00
Raymond Hill 1c2d21d91e
Add missing entries in manifest for new toggle-javascript command
Related issue:
https://github.com/uBlockOrigin/uBlock-issues/issues/692
2024-01-12 17:34:59 -05:00
Raymond Hill 936444883f
Add support to toggle no-scripting switch with keyboard shortcut
Related issue:
https://github.com/uBlockOrigin/uBlock-issues/issues/692
2024-01-12 12:01:23 -05:00
Raymond Hill c03c23d962
Import translation work from https://crowdin.com/project/ublock 2024-01-12 12:00:55 -05:00
Raymond Hill 010cd3f9e0
Import translation work from https://crowdin.com/project/ublock 2024-01-10 12:59:09 -05:00
Raymond Hill 1ea1ff7f4f
Import translation work from https://crowdin.com/project/ublock 2024-01-01 10:30:57 -05:00
Raymond Hill 38bde79146
Use `CSS.supports()` to detect support of native `:has()`
Related issue:
https://github.com/uBlockOrigin/uBlock-issues/issues/2480#issuecomment-1868595930
2023-12-25 09:06:42 -05:00
Raymond Hill 26f45e1fdf
Import translation work from https://crowdin.com/project/ublock 2023-12-23 17:45:36 -05:00
Raymond Hill aa7f77aaad
Split scriptlet filtering engine into lo- and hi-level classes
The idea is to remove as many dependencies as possible for
low-level ScriptletFilteringEngine in order to make it easier
to reuse the module outside uBO itself.

The high-level derived class takes care of caching and
injection of scriptlets into documents, which requires
more knowledge about the environment in which scriptlets
are to be used.

Also improve scriptlet cache usage to minimize overhead of
retrieving scriptlets.
2023-12-21 10:48:01 -05:00
Raymond Hill 462e8fe917
Import translation work from https://crowdin.com/project/ublock 2023-12-19 12:04:22 -05:00
Raymond Hill 1a27f6a6cd
Import translation work from https://crowdin.com/translate/ublock 2023-12-14 10:36:18 -05:00
Raymond Hill acc2950736
[mv3] Fine tuning ruleset output 2023-12-11 09:29:59 -05:00
Raymond Hill af0a3f4abb
[mv3] Have one rule per line in ruleset files 2023-12-09 11:02:20 -05:00
Raymond Hill e789a6b0c5
Import translation work from https://crowdin.com/project/ublock 2023-12-08 10:19:18 -05:00
Raymond Hill b38d89c335
Disable session storage for the time being
Related issue:
https://github.com/uBlockOrigin/uBlock-issues/issues/3003#issuecomment-1841831191
2023-12-05 19:03:04 -05:00
Raymond Hill b8b4193f15
Import translation work from https://crowdin.com/project/ublock 2023-12-04 17:06:06 -05:00
Raymond Hill eb66820728
]firefox] Improve load time & behavior from suspended state
Related issue:
https://github.com/uBlockOrigin/uBlock-issues/issues/2969

Changes:

Use browser.alarms to trigger selfie creation. Presence of a selfie
improve markedly time to readiness when uBO is unsuspended.

Mirror content of storage.local to (in-memory) storage.session for
faster load to readiness when uBO is ususpended.
2023-12-04 15:15:08 -05:00
Raymond Hill a969a672e0
Change official description in source code top comment 2023-12-04 12:10:34 -05:00
Raymond Hill aa584d750b
Import translation work from https://crowdin.com/project/ublock 2023-12-04 08:13:19 -05:00
Raymond Hill ee83a4304a
Isolate DOM inspector layers from page context
Related issue:
https://github.com/uBlockOrigin/uBlock-issues/issues/1411

Additionally, refactored communication mechanism between content
script contexts and uBO contexts by using MessageChannel/BroadcastChannel
web APIs.
2023-12-03 16:21:32 -05:00
Raymond Hill 2c495487f1
Import translation work from https://crowdin.com/project/ublock 2023-12-02 12:59:05 -05:00
Raymond Hill 67fb969572
Refactoring: Replace DOM events with broadcast channels
Broadcast channels are more suited to uBO than DOM events to dispatch
notifications to different parts of uBO.

DOM events can only be dispatched to local context, broadcast channels
dispatch to all contexts (i.e. background process, workers, auxiliary
pages) -- this last behavior is better suited to uBO to communicate
internal changes to all potential listeners, not just those in the local
context.

Additionally, broadcasting to content scripts is now done through
tabs.sendMessage() instead of through potentially opened message
ports, this simplifies broadcasting to content scripts, and this
doesn't require to have long-lived message ports in content
scripts.
2023-12-01 14:35:28 -05:00
Raymond Hill c16fcc1105
Import translation work from https://crowdin.com/project/ublock 2023-11-29 16:19:23 -05:00
Raymond Hill a77c23c74f
[mv3] Improve and cleanup options page
Additionally, ensure the options page stay in sync with the
internal state of the extension.
2023-11-29 16:11:22 -05:00
Raymond Hill 554400f7bd
Import translation work from https://crowdin.com/project/ublock 2023-11-28 21:15:51 -05:00
Raymond Hill d7acad6c90
[mv3] Add textarea to list/edit trusted sites
Related issue:
https://github.com/uBlockOrigin/uBOL-home/issues/29
2023-11-28 21:13:44 -05:00
Raymond Hill 2bd2e6a079
Import translation work from https://crowdin.com/project/ublock 2023-11-28 21:10:29 -05:00
Raymond Hill 4f07df33a1
[mv3] Remove reference to nonexistent ruleset 2023-11-28 11:02:55 -05:00
Raymond Hill 430c578978
Import translation work from https://crowdin.com/project/ublock 2023-11-27 19:04:43 -05:00
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 f77481f740
Import translation work from https://crowdin.com/project/ublock 2023-11-20 12:47:49 -05:00
Raymond Hill e9cab80151
Fix untranslated "Filter lists" in dashboard 2023-11-20 12:36:01 -05:00
Raymond Hill a373efe9c0
Import translation work from https://crowdin.com/project/ublock 2023-11-13 10:34:09 -05:00
Raymond Hill b26d421a57
Add Punjabi (pa) translation 2023-11-12 13:51:50 -05:00
Raymond Hill ce38e6c81a
Import changes following removal of unused i18n strings 2023-11-12 13:50:40 -05:00
Raymond Hill b201c61584
[mv3] Remove unused i18n strings 2023-11-12 13:45:46 -05:00
Raymond Hill 130c437dd3
Import translation work from https://crowdin.com/project/ublock 2023-11-11 10:55:40 -05:00
Raymond Hill 9ebed116da
Import translation work from https://crowdin.com/project/ublock 2023-11-08 19:44:33 -05:00
Raymond Hill 11ebb736ca
Import translation work from https://crowdin.com/project/ublock 2023-11-06 12:16:48 -05:00
Raymond Hill d12d014b10
Import translation work from https://crowdin.com/project/ublock 2023-11-03 19:13:07 -04:00
Raymond Hill 904e5dff7a
Import translation work from https://crowdin.com/project/ublock 2023-10-28 07:41:18 -04:00
Raymond Hill 0b59ebf1c6
Import translation work from https://crowdin.com/project/ublock 2023-10-27 21:27:28 -04:00
Raymond Hill c1657c2f9c
Import translation work from https://crowdin.com/project/ublock 2023-10-24 11:22:21 -04:00
Raymond Hill 6c672c99c2
Import translation work from https://crowdin.com/project/ublock 2023-10-23 09:20:59 -04:00
Raymond Hill 287f7711aa
Import translation work from https://crowdin.com/project/ublock 2023-10-21 08:19:28 -04:00
Raymond Hill 6af4494946
[mv3] Honor scriptlets' target world in Firefox
When the target world of a scriptlet is the ISOLATED one,
skip Blob-based injection in Firefox, as the current world
is always the ISOLATED one. This should make ISOLATED
world-based scriptlets more reliable (i.e. execute sooner)
in Firefox.
2023-10-21 07:11: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 d25306f300
Modify `manifest.json` for other platforms
As per 0325dcdcb4
2023-10-14 13:55:46 -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 fb42411efb
Add `browser_specific_settings.gecko_android` to Firefox manifests
Reference:
https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/browser_specific_settings
2023-10-11 12:32:38 -04:00
Raymond Hill 3a5606125d
Import translation work from https://crowdin.com/project/ublock 2023-10-10 10:42:14 -04:00
Raymond Hill bd71d131a8
Catch unhandled exceptions
Related issue:
https://github.com/uBlockOrigin/uBOL-home/issues/77
2023-10-05 11:25:28 -04:00
Raymond Hill 7416340144
Prune rules with invalid regex-based filter for all realms
Related issue:
https://github.com/uBlockOrigin/uBOL-home/issues/77
2023-10-03 10:51:47 -04:00
Raymond Hill b95c90ba7c
Import translation work from https://crowdin.com/project/ublock 2023-09-22 09:36:01 -04:00
Raymond Hill d005e3f3ac
[mv3] Fix glitchy popup panel when width increases
Related issue:
https://github.com/uBlockOrigin/uBOL-home/issues/66
2023-09-16 12:23:47 -04:00
Raymond Hill ee6de37b6e
[mv3] Rework dashboard to avoid usage of `iframe`
Related issue:
https://github.com/uBlockOrigin/uBOL-home/issues/67
2023-09-16 11:46:39 -04:00
Raymond Hill ba8820fe31
Import translation work from https://crowdin.com/project/ublock 2023-09-08 09:19:26 -04:00
Raymond Hill f8a83fff7c
[mv3] Fine tune for small screens 2023-08-22 20:08:26 -04:00
Raymond Hill 3c7f35ed9c
Import translation work from https://crowdin.com/project/ublock 2023-08-22 10:50:04 -04:00
Raymond Hill f9ba65b829
[mv3] Put icon in nav bar by default
Related issue:
https://github.com/uBlockOrigin/uBlock-issues/issues/2781
2023-08-20 09:35:16 -04:00
Raymond Hill ca6adbca56
[mv3] Point to new uBO version 2023-08-20 08:54:32 -04:00
Raymond Hill 21bb4e56ed
Put uBO's icon in nav bar by default
Related issue:
https://github.com/uBlockOrigin/uBlock-issues/issues/2781
2023-08-20 08:38:42 -04:00
Raymond Hill b1f0c5b773
Typo 2023-08-19 19:56:00 -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