Commit graph

19 commits

Author SHA1 Message Date
Raymond Hill
e55811bbf9
[mv3] Need to setup scriptlet details only once 2026-01-01 13:15:44 -05:00
Raymond Hill
df0d21d92e
[mv3] Avoid instantiating regexes by using simple needle first
Related issue:
https://github.com/uBlockOrigin/uBOL-home/issues/223
2025-12-27 09:45:25 -05:00
Raymond Hill
377cf9d86b
[mv3] Add support for regex-based extended filters
Related issues:
- https://github.com/uBlockOrigin/uBOL-home/issues/223
- https://github.com/uBlockOrigin/uAssets/issues/31261
2025-12-25 12:34:21 -05:00
Raymond Hill
e036156f3a
[mv3] Sort scriptlet functions
To minimize diff between releases.
2025-12-09 12:58:10 -05:00
Raymond Hill
0aa0d81caf
[mv3] Re-work specific cosmetic filtering-related content scripts
To minimize delay to First Contentful Paint. The idea is to avoid
complex data structures such as Map in order to speed up first content
script execution. Use stringified arrays where practical and
instanciate those arrays from their stringified representation only
when there are actual cosmetic filters to apply.

Related commit:
https://github.com/gorhill/uBlock/commit/6039ef2b6d
2025-12-05 08:54:34 -05:00
Raymond Hill
6039ef2b6d
[mv3] Generate at most two scriptlet-related files per rulesets
Related issue:
https://github.com/uBlockOrigin/uBOL-home/issues/557
2025-12-04 12:57:25 -05:00
Raymond Hill
d006fd06e7
[mv3] Add support for ancestor context syntax in scriptlets
Related commit:
a483f7955f
2025-03-07 17:04:02 -05:00
Raymond Hill
8a6b12a319
[mv3] Inject scriptlets in their intended target world 2025-02-24 10:11:13 -05:00
Raymond Hill
6ca28a5b3f
[mv3] Improve output og log.txt 2025-02-22 07:38:12 -05:00
Raymond Hill
703fdf673c
[mv3] Fix mv3 build script 2024-11-27 17:55:18 -05:00
Raymond Hill
4d525f1a55
Move assets/resources into src/js/ 2024-11-27 16:47:11 -05:00
Raymond Hill
a969a672e0
Change official description in source code top comment 2023-12-04 12:10:34 -05: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
bb41d9594f
[mv3] Use workaround to inject scriptlets in Firefox
Additionally:

Use `export UBO_VERSION=local` at the console to build MV3 extension using
current version of uBO code base. By default, the version is taken from
`./platform/mv3/ubo-version' and usually set to last stable release.
2023-08-11 13:22:25 -04:00
Raymond Hill
7ba85472d7
[mv3] Properly distinguish trust level when compiling scriptlets
Since in uBOL filter lists from various sources are combined into
a single list, there must be a way to turn on/off trust level
inside the resulting combined filter list so as to be able to
validate the trust level of filters requiring trust.

This commit adds new parser directives understood only by MV3
compiler to turn on/off trust flag internally.
2023-06-23 08:27:07 -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
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
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