1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-09-29 22:27:12 +02:00
Commit Graph

2421 Commits

Author SHA1 Message Date
Raymond Hill
9c3205b37c
Inject procedural cosmetic filterer's code only when needed
The procedural cosmetic filtering code has been split from
the content script code injected unconditionally and will
from now on be injected only when it is needed, i.e. when
there are procedural cosmetic filters to enforce.

The motivation for this is:
https://www.debugbear.com/blog/2020-chrome-extension-performance-report#what-can-extension-developers-do-to-keep-their-extensions-fast

Though uBO's content script injected unconditionally in all
pages/frames is relatively small, I still wanted to further
reduce the amount of content script code injected
unconditionally: The procedural cosmetic filtering code
represents roughly 14KB of code the browser won't have to
parse/execute unconditionally unless there exists procedural
cosmetic filters to enforce for a page or frame.

At the time the above article was published, the total
size of unconditional content scripts injected by uBO was
~101 KB, while after this commit, the total size will be
~57 KB (keeping in mind uBO does not minify and does not
remove comments from its JavaScript code).

Additionally, some refactoring on how user stylesheets are
injected so as to ensure that `:style`-based procedural
filters which are essentially declarative are injected
earlier along with plain, non-procedural cosmetic filters.
2021-02-17 09:12:00 -05:00
Raymond Hill
435c91636f
Count allowed/blocked requests for 3rd-party scripts/frames
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/210

Additionally, a small (experimental) widget has been added
to emphasize/de-emphasize rows which have 3rd-party
scripts/frames, so as to more easily identify which rows
are "affected" by 3rd-party scripts and/or frames.

Tooltip localization for the new widget is not available
yet as I want wait for the feature to be fully settled.
2021-02-15 06:52:31 -05:00
Raymond Hill
3bb73065e3
Fix broken forward compatibility re. imported lists
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1480

Forward compatiblity was broken due to `externalLists`
being converted into an Array from a string, i.e.
downgrading to uBO 1.32.4 was completely breaking uBO.

This commit restores `externalLists` as a string which
is what older versions of uBO expect.

A new property `importedLists` has been created to
hold the imported lists as an array, while
`externalLists` will be kept around for a while until
it is completely removed in some future.
2021-01-31 10:30:12 -05:00
Raymond Hill
0390bb8b8a
Fix potential spurious redirection in whitelisted tabless contexts
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1478
2021-01-30 15:08:21 -05:00
Raymond Hill
3101c5fa22
Upload non-filtered rules to cloud storage
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1472
2021-01-28 09:43:14 -05:00
Raymond Hill
40c145d76a
Fix handling of cname-aliased URLs in click-to-load widget
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1455
2021-01-22 09:37:12 -05:00
Raymond Hill
174731851e
Minor fine tuning of some default parameters 2021-01-21 08:40:10 -05:00
Raymond Hill
6eb1246508
Add userSettings entry to managed storage
The managed `userSettings` entry is an array of entries,
where each entry is a name/value pair encoded into an array
of strings.

The first item in the entry array is the name of a setting,
and the second item is the stringified value for the
setting.

This is a more convenient way for administrators to set
specific user settings. The settings set through
`userSettings` policy will always be set at uBO launch
time.
2021-01-16 10:35:56 -05:00
Raymond Hill
649b3480e0
Add "toOverwrite.filters" entry as managed storage property
The new entry is an array of strings, each representing a
distinct line, and all entries are used to populate the
"My filters" pane.

This offers an more straightforward way for administrators
to specify a list of custom filters to use for all
installations.
2021-01-10 12:31:31 -05:00
Raymond Hill
114012ae11
Add ability to lookup effective context from store of frames
Content scripts can't properly look up effective context
for sandboxed frames. This commit add ability to extract
effective context from already existing store of frames
used for each tab.
2021-01-10 11:56:27 -05:00
Raymond Hill
03e1b16961
Fix content script's broken context lookup from sandboxed anonymous frames 2021-01-08 13:12:48 -05:00
Raymond Hill
0e3071dd50
Add filterLists property to managed storage
The entry `toOverwrite.filterLists` is an array of
string, where each string is a token identifying a
stock filter list, or a URL for an external filter
list.

This new entry is to make it easier for an
administrator to centrally configure uBO with a
custom set of filter lists.
2021-01-08 09:18:26 -05:00
Raymond Hill
e4e7cbc78f
Use better identifying name for overview panel 2021-01-07 08:19:47 -05:00
Raymond Hill
1fcc3c6ddc
Add URL as tooltip 2021-01-07 08:19:02 -05:00
Raymond Hill
cc9c45f1e4
Adding to and further reviewing admin-managed settings 2021-01-06 11:39:24 -05:00
Raymond Hill
2ab11603f0
Allow everybody to use now-stable queryprune=
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/760
2021-01-06 11:17:07 -05:00
Raymond Hill
c1130ec843
Add support for admin-managed hidden settings
Related discussion:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1437#issuecomment-754127066
2021-01-05 12:16:50 -05:00
Raymond Hill
b28acfccbc
Add "extraTrustedSiteDirectives" as new admin policy
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1433

The new "extraTrustedSiteDirectives" policy is an array
of strings, each of which is parsed as a trusted-site
directive to append to a user's own set of trusted-site
directives at launch time.

The added trusted-site directives will be considered as
part of the default set of directives by uBO.
2021-01-04 07:54:24 -05:00
Raymond Hill
2bb33aac20
Be sure to use only a valid journal slot pointer
Related commit:
- 70cabc1cc6
2021-01-02 12:41:13 -05:00
Raymond Hill
752191a04f
Make sure journal slot pointers are properly reset
For when the same page store is recycled later.
2021-01-02 12:07:31 -05:00
Raymond Hill
70cabc1cc6
Better report secondary requests with quick redirections
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1241

uBO will not discard secondary requests fired before a root
frame is committed, by ensuring that if newly uncommitted
root frames are of the same origin as previous one(s), the
uncommited journal slot pointer is not updated.
2021-01-02 11:52:16 -05:00
Raymond Hill
c2357c5cd6
Just extract token from queryprune -- don't create pattern
Related commit:
- 6ac09a2856

Patternless `queryprune` ar enow preserved as being
pattern-less while still attempting to extract a token
from the `queryprune` value. This allows to report the
filter in the logger same as its original form.
2021-01-01 10:23:40 -05:00
Raymond Hill
1669d122df
Add resource for noop VMAP
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1425

The resource content is a copy/paste of AdGuard's code:
- bc5eec1989/src/redirects/static-redirects.yml (L134)
2020-12-29 09:05:28 -05:00
Raymond Hill
2e7f1b8d08
Improve validation of synctactically bad regexes
The following regex are not rejected as invalid when
using built-in regex objects:

    /abc]/
    /a7,18}/
    /a{7,18/

However, as per documentation, they are not supposed to
be valid, as `{` and `}` are special characters and as
such should be escaped:

    /abc\]/
    /a7,18\}/
    /a\{7,18/

With this commit, the regexes will additionally be
validated using the regex analyzer library in the editor
to ensure strict regex syntax compliance so as to avoid
what are likely mistakes in regex crafting by authors.
2020-12-28 07:13:57 -05:00
Raymond Hill
4ba3adc28c
Fix comment 2020-12-28 07:07:04 -05:00
Raymond Hill
d910111d4a
Fix parsing of trailing resource
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1419
2020-12-28 07:03:52 -05:00
Raymond Hill
6d3ad553b4
Fix word-based selection in filter list editor/viewer
This commit fixes mouse double-click-and-drag operations,
which was broken due to the implementation of a custom
word selection in the filter list editor/viewer.
2020-12-27 09:32:50 -05:00
Raymond Hill
b053477087
Fix potentially missing context in logger for popup entries
Reported internally.
2020-12-26 10:15:07 -05:00
Raymond Hill
426395aa03
Improve extraction of tokens from regex-based filters
Regex-based static network filters are those most likely to
cause performance degradation, and as such the best guard
against undue performance degradation caused by regex-based
filters is the ability to extract valid and good tokens
from regex patterns.

This commit introduces a complete regex parser so that the
static network filtering engine can now safely extract
tokens regardless of the complexity of the regex pattern.

The regex parser is a library imported from:
https://github.com/foo123/RegexAnalyzer

The syntax highlighter adds an underline to regex-based
filters as a visual aid to filter authors so as to avoid
mistakenly creating regex-based filters. This commit
further colors the underline as a warning when a regex-based
filter is found to be untokenizable.

Filter list authors are invited to spot these untokenizable
regex-based filters in their lists to verify that no
mistake were made for those filters, causing them to be
untokenizabke. For example, what appears to be a mistake:

    /^https?:\/\/.*\/sw.js?.[a-zA-Z0-9%]{50,}/

Though the mistake is minor, the regex-based filter above
is untokenizable as a result, and become tokenizable when
the `.` is properly escaped:

    /^https?:\/\/.*\/sw\.js?.[a-zA-Z0-9%]{50,}/

Filter list authors can use this search expression in the
asset viewer to find instances of regex-based filters:

    /^(@@)?\/[^\n]+\/(\$|$)/
2020-12-26 08:52:42 -05:00
Raymond Hill
596f085fa5
Allow default word selection when not using better selection
Double-click in editor will just fall back to default word
selection when NOT using enhanced word selection.
2020-12-24 08:34:45 -05:00
Raymond Hill
1c37e29e0a
Fix handling of fragment when applying queryprune
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1415
2020-12-24 07:35:26 -05:00
Raymond Hill
ea71e93c81
Reset Chromium-specific color-scheme CSS property
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1408
2020-12-21 09:20:56 -05:00
Raymond Hill
187f1831f0
Allow more local resources to be redirected as data: URIs
Related feedback:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1388#issuecomment-748625280
2020-12-20 11:54:24 -05:00
Raymond Hill
990cff576d
Fix case of scriptlet injection not working about: frames
This is an issue in uBO affecting only Chromium-based browsers.

Related feedback:
https://github.com/uBlockOrigin/uBlock-issues/issues/688#issuecomment-748179731
2020-12-18 12:07:08 -05:00
Raymond Hill
a307cf5e6a
Mind restore-from-backup for no-csp-reports rule
Related commit:
- 7d90f97aa1
2020-12-17 08:12:06 -05:00
Raymond Hill
bc9b8a1330
Enable broad no-csp-reports rule only in Firefox
Related commit:
- 7d90f97aa1
2020-12-16 07:02:55 -05:00
Raymond Hill
89cac090a4
Mind important only for valid redirect tokens
Related feedback:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1366#issuecomment-745744824
2020-12-16 06:55:46 -05:00
Raymond Hill
a090b2b564
Fix auto-completion for epicker in Firefox 2020-12-15 09:38:20 -05:00
Raymond Hill
0052dc123b
Fix no-csp-reports default enabled switch state
Related feedback:
- 7d90f97aa1 (commitcomment-45138096)
2020-12-15 09:36:04 -05:00
Raymond Hill
e28c2cc3c6
Auto-complete of origin pattern for ||-based patterns
Related commit:
- daf464b3c3
2020-12-15 08:27:59 -05:00
Raymond Hill
8060ddb283
Avoid duplicates in editor's auto-completion of origins
Related commit:
- daf464b3c3
2020-12-14 11:26:04 -05:00
Raymond Hill
b22cf24bd5
Fix look-up of specific-generic filters entity-less hostnames
Related feedback:
- https://github.com/uBlockOrigin/uBlock-issues/issues/688#issuecomment-743755956
2020-12-14 11:22:08 -05:00
Raymond Hill
d4425ad753
Fix bad access to hostname info from filtering context
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1398

Regression from:
- 6df32675b1
2020-12-14 08:38:30 -05:00
Raymond Hill
1ff8132216
Simplify code
Related commit:
- b779f1f7c9
2020-12-13 12:14:37 -05:00
Raymond Hill
18e6f30c1c
Minor code review
Related commit:
- 6df32675b1
2020-12-12 14:38:44 -05:00
Raymond Hill
b779f1f7c9
Dynamically reload 3p css when noop-ing "3rd-party" cell
This should improve usability of uBO's hard-mode
and "relax blocking mode" operations. This is the
new default behavior.

The previous behavior of forcing a reload of the
page can be re-enabled by simply setting the `3p`
bit of the advanced setting `blockingProfiles`
to 1.
2020-12-12 14:33:49 -05:00
Raymond Hill
6df32675b1
Add approximate reporting of tabless network requests
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1204

Not much can be done beside reporting to tabless network
requests to all tabs for which the context is a match.

A short term local cache is used to avoid having to iterate
through all existing tabs for each tabless network request
just to find and report to the matching ones -- users
reporting having a lot of opened tabs at once is not so
uncommon.
2020-12-12 08:19:40 -05:00
Raymond Hill
7d90f97aa1
Enable the blocking of CSP reports by default
Related issue:
- https://github.com/LiCybora/NanoDefenderFirefox/issues/196
2020-12-11 12:34:09 -05:00
Raymond Hill
24755d4300
Fix broken alias nostif
Related feedback:
- ba11a70013 (r45030152)

Regression from:
- ba11a70013
2020-12-11 10:34:33 -05:00
Raymond Hill
cb71fb494c
Fix DOM watcher not reporting removal of elements
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1392

Regression from:
- 6112a68faf
2020-12-10 12:51:26 -05:00
Raymond Hill
15afd59e1e
Fix unstyling of nodes no longer matching procedural filters
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1392

Regression from:
- 35aefed926
2020-12-10 10:03:15 -05:00
Raymond Hill
0b5f53923f
Add basic compatibility with ABP's rewrite option
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/857

The recognized resources are:
- abp-resource:blank-mp3
- abp-resource:blank-js

ABP's tokens are excluded from auto-complete so as to not
get in the way of uBO's filter list maintainers.
2020-12-09 08:16:28 -05:00
Raymond Hill
3ff6617ea3
Fix block filter reported in the logger despite being excepted
Reported internally by @uBlock-user.

Also, fixed broken caching of `cname` exception, which forced
uBO to repeatedly evaluate whether a `cname` exception exists
when a block `cname`-cloaked request is encountered.
2020-12-08 11:16:17 -05:00
Raymond Hill
9aef41738b
Prevent non-stable uiTheme from being used in stable build
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1389

Asking people to respect the warning in the documentation
does not work, consequently the setting will be now disabled
for stable releases.
2020-12-08 10:11:34 -05:00
Raymond Hill
5d7b2918ef
Harden processing of changes in compiled list format
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1365

This commit adds the compiled magic version number to the
compiled data itself, and consequently this allows uBO
to no longer require that any given compiled list with a
mismatched format to be detected and discarded at launch
time.

Given this change, uBO no longer needs to rely on the
deletion of cached data at launch time to ensure it
won't use no longer valid compiled lists.
2020-12-08 10:00:47 -05:00
Raymond Hill
780b605bad
Fix missing magnifier in document-blocked page
Related feedback:
- e559cb73b9 (commitcomment-44887972)

Regression from:
- e559cb73b9
2020-12-07 14:32:59 -05:00
Raymond Hill
904aa87e2a
Fix various regression in behavior of redirect-rule=
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1388

Fixed the special `none` redirect resource no longer being
enforced.

Fixed the enforcement of `important` redirect rules over
exceptions and non-important ones.
2020-12-07 11:12:41 -05:00
Raymond Hill
5d7a5a559d
Fix broken redirect-rule= priority parser
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1388

Regression from:
- cf2c638d8e
2020-12-07 10:49:05 -05:00
Raymond Hill
e559cb73b9
Complete removal of font-based Fontawesome icons
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/249
2020-12-06 11:24:04 -05:00
Raymond Hill
db7f54dbf6
Add support to launch element picker in embedded frames
Related issue:
- https://github.com/gorhill/uBlock/issues/1744

A new context menu entry, "Block element in frame...", will
be present when right-clicking on a frame element. When
this entry is clicked, uBO's element picker will be
launched from within the embedded frame and function the
same way as when launched from within the page.
2020-12-05 15:26:29 -05:00
Raymond Hill
c77f697b4b
Reuse duplicate strings stored in tries
This is particularly helpful for static network filters
used with filter options causing the same pattern to be
reused across multiple filter instances, i.e. `all` or
`~css`, etc.
2020-12-04 07:53:01 -05:00
Raymond Hill
e8e4a1ac74
Wait for removal of storage entries to be completed
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1365

When compiled data format changes, do not rely on order
of operations at launch to assume deletion of storage
occurs before attempts to access it. It's unclear this
commit will fix the reported issue, as I could not
reproduce it except when outright commenting out the code
to prevent the storage deletion from occurring.
2020-12-04 06:17:18 -05:00
Raymond Hill
da9d068243
Fix improper typeof test for string type
Regression from:
- b12e0e05ea

This broke the ability to provide a link to the actual
asset on the remote server in the asset viewer.
2020-12-03 11:52:49 -05:00
Raymond Hill
1de8349045
Fix hint helper in element picker's text editor
Regression from:
- 262a1a044f
2020-12-03 07:34:50 -05:00
Raymond Hill
ee87bda326
Fix regression in syntax rendering of redirect values in asset viewer
Related commit:
- 262a1a044f
2020-12-02 13:07:29 -05:00
Raymond Hill
262a1a044f
Improve auto-complete of hostname values in "My filters"
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1134

Related commit:
- daf464b3c3
2020-12-02 09:09:28 -05:00
Raymond Hill
26dc7a1490
Minor review of redirect-related code
Notably, I finally settled for implicit priority of
0, but now negative priority values are allowed.
2020-12-02 08:18:55 -05:00
Raymond Hill
cf2c638d8e
Improve reporting of matching redirect= rules in logger
All matching `redirect-rule` directives will now be reported
in the logger, instead of just the effective one.

The highest-ranked redirect directive will be the one
effectively used for redirection. This way filter list
authors can see whether a lower priority redirect is
being overriden by a higher priority one.

The default priority has been changed to 10, so as to allow
more leeway to create lower ranked redirect directives.

Additonally, rendering of redirect directives with explicit
priority has been fixed in the logger, they will no longer
be rendered as unknown redirect tokens.
2020-12-01 09:29:40 -05:00
Raymond Hill
e08f8cb001
Make queryprune an exact alias of removeparam
As per agreed upon discussion, `queryprune` now follows
exactly the syntax of AdGuard's `removeparam`.

Related discussion:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1356

Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/760

For the short term, `queryprune` will still interpret a
leading `|` to mean "anchor to start of name", until no
such filters are present in uBO's own filter lists.
2020-11-30 12:52:37 -05:00
Raymond Hill
391a5c99c7
Fix the parsing of unsupported static network filter types
Related issue:
- https://github.com/gorhill/uBlock/issues/2283

This is a regression causing the referenced issue to no
longer be fixed. The regression was introduced when the
new static filtering parser code was introduced in version
1.28.0:

https://github.com/gorhill/uBlock/releases/tag/1.28.0
2020-11-30 12:02:36 -05:00
Raymond Hill
5db8d05975
Better align syntax of header= option to that of queryprune=
The header value is no longer implicitly a regex-based literal, but
a plain string against which the header name is compared. The value can
be set to a regex literal by bracing the header value with the usual
forward slashes, `/.../`.

Examples:

    *$1p,strict3p,script,header=via:1.1 google
    *$1p,strict3p,script,header=via:/1\.1\s+google/

The first form will cause a strict comparison with the value of the header
named `via` against the string `1.1 google`.

The second form will cause a regex-based test with the value of the header
named `via` against the regex `/1\.1\s+google/`.

The header value can be prepended with `~` to reverse the comparison:

    *$1p,strict3p,script,header=via:~1.1 google

The header value is optional and may be ommitted to test only for the
presence of a specific header:

    *$1p,strict3p,script,header=via
2020-11-30 09:09:37 -05:00
Raymond Hill
ed64039912
Rename method 2020-11-29 14:03:33 -05:00
Raymond Hill
40a7c47bfc
Properly handle instances of #?# or #$# in picker
Related feedback:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1363#issuecomment-734957406
2020-11-29 11:31:20 -05:00
Raymond Hill
d1895d4749
Another round of fine-tuning queryprune= syntax
Related discussions:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1356#issuecomment-732411286
- https://github.com/AdguardTeam/CoreLibs/issues/1384

Changes:

Negation character is `~` (instead of `!`).

Drop special anchor character `|` -- leading `|`
will be supported until no such filter is present
in uBO's own filter lists. For example, instance
of `queryprune=|ad` will have to be replaced with
`queryprune=/^ad/` (or `queryprune=ad` if the name
of the parameter to remove is exactly `ad`).

Align semantic with that of AdGuard's `removeparam=`,
except that specifying multiple `|`-separated names
is not supported.
2020-11-29 11:02:40 -05:00
Raymond Hill
dac8d6becb
Fix broken token extraction
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1367

Regression from:
- 6ac09a2856

Need to mind wildcards adjacent to extracted token.
2020-11-29 07:38:15 -05:00
Raymond Hill
eae7cd58fe
Add support for match-case option; fine-tune behavior of redirect=
`match-case`
------------

Related issue:
- https://github.com/uBlockOrigin/uAssets/issues/8280#issuecomment-735245452

The new filter option `match-case` can be used only for
regex-based filters. Using `match-case` with any other
sort of filters will cause uBO to discard the filter.

`redirect=`
-----------

Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1366

`redirect=` filters with unresolvable resource token at
runtime will be discarded.

Additionally, the implicit priority is now set to 1
(was 0). The idea is to allow custom `redirect=` filters
to be used strictly as fallback `redirect=` filters in case
another `redirect=` filter is not picked up.

For example, one might create a `redirect=click2load.html:0`
filter, to be taken if and only if the blocked resource is
not already being redirected by another "official" filter
in one of the enabled filter lists.
2020-11-28 11:26:28 -05:00
Raymond Hill
c6d0204b23
Remove requirement for presence of type with redirect= option
Related issue:
- https://github.com/gorhill/uBlock/issues/3590

Since the `redirect=` option was refactored into a modifier
filter, presence of a type (`script`, `xhr`, etc.) is no
longer a requirement.
2020-11-28 08:52:18 -05:00
Raymond Hill
ab5ab8575c
Avoid re-assigning asset cache registry at launch
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1365
2020-11-28 08:28:20 -05:00
Raymond Hill
c959fd6cd9
Fix comment 2020-11-27 16:01:34 -05:00
Raymond Hill
6ac09a2856
Add ability to parse removeparam= as queryprune=
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1356

Related commit:
- bde3164eb4

It is not possible to achieve perfect compatiblity at this
point, but reasonable compatibility should be achieved for
a majority of instances of `removeparam=`.

Notable differences:
--------------------

uBO always matches in a case insensitive manner, there is
no need to ask for case-insensitivity, and no need to use
uppercase characters in `queryprune=` values.

uBO does not escape special regex characters since the
`queryprune=` values are always assumed to be literal
regex expression (leaving out the documented special
characters). This means `removeparam=` with characters
which are special regex characters won't be properly
translated and are unlikely to work properly in uBO.

For example, the `queryprune` value of a filter such as
`$removeparam=__xts__[0]` internally become the literal
regex `/__xts__[0]/`, and consequently would not match
a query parameter such as `...?__xts__[0]=...`.

Notes:
------

Additionally, for performance reason, when uBO encounter
a pattern-less `queryprune=` (or `removeparam=`) filter,
it will try to extract a valid pattern from the
`queryprune=` value. For instance, the following filter:

    $queryprune=utm_campaign

Will be translated internally into:

    utm_campaign$queryprune=utm_campaign

The logger will reflect this internal translation.
2020-11-26 09:34:12 -05:00
Raymond Hill
80413dff83
Fix forgotton instances of 1P/3P
Related commit:
- 60d5b85e41

Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1362
2020-11-26 05:43:14 -05:00
Raymond Hill
60d5b85e41
Rename 1P/3P tp strict1p/strict3p as suggested
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1362
2020-11-26 05:09:46 -05:00
Raymond Hill
57013c16e6
Fix compilation of blocking counterpart of redirect= filters
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1358
2020-11-25 09:36:12 -05:00
Raymond Hill
e45949417b
Magic compile/selfie numbers need to increased
Related commit:
- bde3164eb4
2020-11-23 10:26:15 -05:00
Raymond Hill
43cb63f80a
Fix parsing of queryprune=* in static filtering parser 2020-11-23 08:47:29 -05:00
Raymond Hill
bde3164eb4
Add support for 1P, 3P, header= filter options and other changes
New filter options
==================

Strict partyness: `1P`, `3P`
----------------------------

The current options 1p/3p are meant to "weakly" match partyness, i.e. a
network request is considered 1st-party to its context as long as both the
context and the request share the same base domain.

The new partyness options are meant to check for strict partyness, i.e. a
network request will be considered 1st-party if and only if both the context
and the request share the same hostname.

For examples:

- context: `www.example.org`
- request: `www.example.org`
- `1p`: yes, `1P`: yes
- `3p`: no,  `3P`: no

- context: `www.example.org`
- request: `subdomain.example.org`
- `1p`: yes, `1P`: no
- `3p`: no,  `3P`: yes

- context: `www.example.org`
- request: `www.example.com`
- `1p`: no, `1P`: no
- `3p`: yes,  `3P`: yes

The strict partyness options will be visually emphasized in the editor so as
to prevent mistakenly using `1P` or `3P` where weak partyness is meant to be
used.

Filter on response headers: `header=`
-------------------------------------

Currently experimental and under evaluation. Disabled by default, enable by
toggling `filterOnHeaders` to `true` in advanced settings.

Ability to filter network requests according to whether a specific response
header is present and whether it matches or does not match a specific value.

For example:

    *$1p,3P,script,header=via:1\.1\s+google

The above filter is meant to block network requests which fullfill all the
following conditions:

- is weakly 1st-party to the context
- is not strictly 1st-party to the context
- is of type `script`
- has a response HTTP header named `via`, which value matches the regular
  expression `1\.1\s+google`.

The matches are always performed in a case-insensitive manner.

The header value is assumed to be a literal regular expression, except for
the following special characters:

- to anchor to start of string, use leading `|`, not `^`
- to anchor to end of string, use trailing `|`, not `$`
- to invert the test, use a leading `!`

To block a network request if it merely contains a specific HTTP header is
just a matter of specifying the header name without a header value:

    *$1p,3P,script,header=via

Generic exception filters can be used to disable specific block `header=`
filters, i.e. `@@*$1p,3P,script,header` will override the block `header=`
filters given as example above.

Dynamic filtering's `allow` rules override block `headers=` filters.

Important: It is key that filter authors use as many narrowing filter options
as possible when using the `header=` option, and the `header=` option should
be used ONLY when other filter options are not sufficient.

More documentation justifying the purpose of `header=` option will be
provided eventually if ever it is decided to move it from experimental to
stable status.

To be decided: to restrict usage of this filter option to only uBO's own
filter lists or "My filters".

Changes
=======

Fine tuning `queryprune=`
-------------------------

The following changes have been implemented:

The special value `*` (i.e. `queryprune=*`) means "remove all query
parameters".

If the `queryprune=` value is made only of alphanumeric characters
(including `_`), the value will be internally converted to regex  equivalent
`^value=`. This ensures a better future compatibility with AdGuard's
`removeparam=`.

If the `queryprune=` value starts with `!`, the test will be inverted. This
can be used to remove all query parameters EXCEPT those who match the
specified value.

Other
-----

The legacy code to test for spurious CSP reports has been removed. This
is no longer an issue ever since uBO redirects to local resources through
web accessible resources.

Notes
=====

The following new and recently added filter options are not compatible with
Chromium's manifest v3 changes:

- `queryprune=`
- `1P`
- `3P`
- `header=`
2020-11-23 08:22:43 -05:00
Raymond Hill
daf464b3c3
Add support to auto-complete values of domain lists
The auto-complete feature in the _"My filters"_ pane will
use hostname/domain from the set of opened tabs to assist
in entering values for `domain=` option. This also works
for the implict `domain=` option ṗrepending static extended
filters.
2020-11-21 09:57:54 -05:00
Raymond Hill
8d3c4916b0
Skip trying to find effective context for about:srcdoc frames
`about:srcdoc` frames are their own origin, trying to
use the origin of the parent context causes an
exception to be thrown when accessing location.href.
2020-11-21 09:51:14 -05:00
Raymond Hill
13f6bdae37
Improve representation of modifier filters in logger
As per feedback from filter list maintainers.
2020-11-20 07:14:02 -05:00
Raymond Hill
ab98cd46b1
Bring back action/state highlighting in _"My rules"_ 2020-11-20 05:34:56 -05:00
Raymond Hill
b1c55b3de9
Emphasize entity portion of hostnames in _"My rules"_ 2020-11-19 11:33:09 -05:00
Raymond Hill
38cecddcd1
Improve zapper's detection of scroll-locked documents 2020-11-18 14:11:36 -05:00
Raymond Hill
ee2fd45f00
Ensure we do not extract truncated URL for Homepage directive
Related feedback:
- b12e0e05ea (commitcomment-44309540)
2020-11-18 12:14:23 -05:00
Raymond Hill
b12e0e05ea
Extract Homepage URL from a list when present
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1346

Additionally, fixed a case of filter list being compiled
twice at subscription time.
2020-11-18 10:02:22 -05:00
Raymond Hill
d87a3b950f
Sort on base domains rather than TLDs in "My rules" pane
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1293
2020-11-18 08:01:00 -05:00
Raymond Hill
a683297931
Fix type assignment in logger page
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1349
2020-11-17 11:18:59 -05:00
Raymond Hill
e360e90d1e
Fix invalid support URL in document-blocked page
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1345
2020-11-15 10:19:09 -05:00
Raymond Hill
46d7f8a70c
Fine tune click-to-load widget
Notably, add clickable link to open the widget
in its own tab. Also, allows the URL to be text-
selected so that it becomes possible to use the
selection in a browser contextual menu's "Open
in a new tab" option.
2020-11-14 08:34:47 -05:00
Raymond Hill
5cf9bcf27c
Fine tune code of optimizeOriginHitTests()
Related commit:
- b265f2644d
2020-11-14 07:28:51 -05:00
Raymond Hill
4afb3dc149
Allow domain= with entity values into pre-test buckets
Related commit:
- b265f2644d

Filters which have `domain=` option with an entity
value will no longer be prevented from joining
pre-test buckets.
2020-11-14 07:04:21 -05:00
Raymond Hill
56cd238ad4
Disable auto activation of dark theme in next release
Until a fully usable dark theme is available. uBO's
incomplete dark theme can still be forced by setting
advanced setting `uiTheme` to `dark`.
2020-11-13 12:15:29 -05:00
Raymond Hill
eb8433cb19
Enable cloud storage compression by default in next release
Related commit:
- d8b6b31eca
2020-11-13 12:14:06 -05:00
Raymond Hill
2cfeaddbed
Fine tune various static filtering code
Notably, make `queryprune` option available only
to filter list authors, until there are guards
against bad filters in some future and until the
option syntax and behavior is fully settled.

Instances of `queryprune` in filter lists will be
compiled, however instances of `queryprune` in
_"My filters"_ will be ignored unless users
indicated they are a filter list author.
2020-11-13 09:23:25 -05:00
Raymond Hill
525d7b1b3b
Fine tune port connection code
Related commit:
- a223031b98
2020-11-13 08:32:51 -05:00
Raymond Hill
02b4d149e3
Do not skip querypruning when no-strict-blocking is true
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1341
2020-11-13 08:30:43 -05:00
Raymond Hill
a223031b98
Work around Firefox's data: favIconUrl leak
Related issue:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1652925
2020-11-12 12:14:59 -05:00
Raymond Hill
280dd8ddd6
Fix picker use of extraneous body in suggested filter
Related feedback:
- https://www.reddit.com/r/uBlockOrigin/comments/jregqx/
2020-11-11 09:39:07 -05:00
Raymond Hill
cfb050f521
Detect bad queryprune values
`queryprune=` values are used as literal regex
value after converting leading/trailing `|` into
`^`/`$`.
2020-11-11 08:15:39 -05:00
Raymond Hill
8cc3779fb3
Last commit changes compiled format 2020-11-11 08:15:27 -05:00
Raymond Hill
0e851c035e
Revisit realm & action bits
The important bit is now considered an action bit
so that there is no more a need for the `important`
property in the parser. The modify bit is now
considered a realm bit.

When the modify bit is set, the action bits become
available to be used to further narrow the realm.
This could be useful in the future if we want to
spread the population of modifier filters across
different buckets.
2020-11-11 07:53:46 -05:00
Raymond Hill
32eca67154
Reuse one instance of domain option iterator
Reusing the same iterator instance for all cases
of `domain=` option parsing should reduce memory
churning.

Additonally, fine tune regex used to extract
valid token from regex-based filters to increase
likelihood of being able to extract a valid
token.
2020-11-10 12:49:46 -05:00
Raymond Hill
8985376b00
Fix timing issue with cached redirection to web accessible resources
Reported internally by @gwarser.

In rare occasion, a timing issue could cause uBO to redirect
to a web accessible resource meant to be used for another
network request. This is a regression introduced with the
following commit:

- 2e5d32e967

Additionally, I identified another issue which would cause
cached redirection to fail when a cache entry with redirection
to a web accessible resource was being reused, an issue which
could especially affect pages which are generated dynamically
(i.e. without full page reload).
2020-11-10 10:43:26 -05:00
Raymond Hill
76ef4811a3
Fix queryprune for tabless requests
Related feedback:
- https://github.com/uBlockOrigin/uBlock-issues/issues/760#issuecomment-724693549
2020-11-10 08:58:39 -05:00
Raymond Hill
0196993828
Use buffer-like approach for filterUnits array
filterUnits is now treated as a buffer which is
pre-allocated and which will grow in chunks so as
to minimize memory allocations. Entries are never
released, just null-ed.

Additionally, move urlTokenizer into the static
network filtering engine, since it's not used
anywhere else.
2020-11-09 06:54:51 -05:00
Raymond Hill
db4f02199d
Convert filterSequences into a const variable
Making filterSequences constant allows to no longer
mind how the array is accessed in loops.
2020-11-08 16:00:24 -05:00
Raymond Hill
50da6706a4
Code review of static network filtering engine
- Convert this.categories Map() into an array;

- Fix case of potentially using an invalid UintArray32
  (regression from latest changes)
2020-11-08 13:50:36 -05:00
Raymond Hill
96bfe3c9a7
Convert filterUnits into a const variable
Making filterUnits constant allows to no longer
mind how the array is accessed in loops.
2020-11-08 10:30:47 -05:00
Raymond Hill
cb91d167d1
Fine tune static network filtering engine code
Notably, defer the post-load optimization operations
to a few seconds after the filters have been all
loaded in memory -- this is not a critical step for
the filtering engine to work properly, hence this
can be delayed in order to ensure readiness as soon
as possible.
2020-11-07 13:25:01 -05:00
Raymond Hill
efea83a825
Incrementally improve static filtering parser
Most notably, the `denyallow=` option now requires
the presence of a valid `domain=` option to not be
rejected.

Using `denyallow=` without narrowing down using the
`domain=` option leads to catastrophic blocking
behvior, hence the requirement for a valid `domain=`
option.
2020-11-07 13:20:02 -05:00
Raymond Hill
1d679143d2
Enable origin-hit coalescing optimisation for modifier filters
Related commit:
- b265f2644d

The optimization in the commit above was meant to
improve the performance of lookup operations of
modifier filters, but I forgot to enable the
optimisation for that class of filters.

This means this commit brings another significant
performance gain on top of the previous commit, as
shown by the built-in benchmark.

Additionally a few minor code rearrangements.
2020-11-06 18:24:46 -05:00
Raymond Hill
b265f2644d
Coallesce origin hit filters into their own bucket
Performance-related work.

There is a fair number of filters which can't be tokenized
in uBO's own filter lists. Majority of those filters also
declare a `domain=` option, examples:

    *$script,redirect-rule=noopjs,domain=...
    *$script,3p,domain=...,denyallow=...
    *$frame,3p,domain=...

Such filters can be found in uBO's asset viewer using the
following search expression:

    /^\*?\$[^\n]*?domain=/

Some filter buckets will contain many of those filters, for
instance one of the bucket holding untokenizable `redirect=`
filters has over 170 entries, which must be all visited when
collating all matching `redirect=` filters.

When a bucket contains many such filters, I found that it's
worth to extract all the non-negated hostname values from
`domain=` options into a single hntrie and perform a pre-test
at match() time to find out whether the current origin of a
network request matches any one of the collected hostnames,
so as to avoid iterating through all the filters.

Since there is rarely a match() for vast majority of network
requests with `domain=` option, this pre-test saves a good
amount of work, and this is measurable with the built-in
benchmark.
2020-11-06 12:04:03 -05:00
Raymond Hill
19331f1ab5
Fine tune latest changes for performance
Related commits:
- 157cef6034
- 1e2eb037e5
2020-11-04 07:50:51 -05:00
Raymond Hill
157cef6034
Re-classify redirect= option as a modifier option
This commit moves the parsing, compiling and enforcement
of the `redirect=` and `redirect-rule=` network filter
options into the static network filtering engine as
modifier options -- just like `csp=` and `queryprune=`.

This solves the two following issues:

- https://github.com/gorhill/uBlock/issues/3590
- https://github.com/uBlockOrigin/uBlock-issues/issues/1008#issuecomment-716164214

Additionally, `redirect=` option is not longer afflicted
by static network filtering syntax quirks, `redirect=`
filters can be used with any other static filtering
modifier options, can be excepted using `@@` and can be
badfilter-ed.

Since more than one `redirect=` directives could be found
to apply to a single network request, the concept of
redirect priority is introduced.

By default, `redirect=` directives have an implicit
priority of 0. Filter authors can declare an explicit
priority by appending `:[integer]` to the token of the
`redirect=` option, for example:

    ||example.com/*.js$1p,script,redirect=noopjs:100

The priority dictates which redirect token out of many
will be ultimately used. Cases of multiple `redirect=`
directives applying to a single blocked network request
are expected to be rather unlikely.

Explicit redirect priority should be used if and only if
there is a case of redirect ambiguity to solve.
2020-11-03 09:15:26 -05:00
Raymond Hill
9c43a48445
URLSearchParams() can't be iterated as a Map()
Related feedback:
- https://github.com/uBlockOrigin/uBlock-issues/issues/760#issuecomment-720434320
2020-11-02 07:41:21 -05:00
Raymond Hill
d536c7ab11
Use const when value does not change 2020-11-02 04:57:42 -05:00
Raymond Hill
5468b92643
Built-in redirect token none must be seen as valid
Related feedback:
- 1727585faa (commitcomment-43787843)
2020-11-02 04:52:47 -05:00
Raymond Hill
f76471f56b
Fix bad pruning logic
Related feedback:
- https://github.com/uBlockOrigin/uBlock-issues/issues/760#issuecomment-720140135
2020-11-02 04:51:40 -05:00
Raymond Hill
c75b27c052
Fix top document partyness
Reported internally.

Regression from:
- 1e2eb037e5

Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/760
2020-11-01 06:25:26 -05:00
Raymond Hill
64dc5f7807
Fix wrongly reported network filter options in logger
Regression from:
- 1e2eb037e5

Related feedback:
- 1e2eb037e5 (commitcomment-43759481)
2020-10-31 13:47:35 -04:00
Raymond Hill
1e2eb037e5
Add new filter option queryprune=
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/760

The purpose of this new network filter option is to remove
query parameters form the URL of network requests.

The name `queryprune` has been picked over `querystrip`
since the purpose of the option is to remove some
parameters from the URL rather than all parameters.

`queryprune` is a modifier option (like `csp`) in that it
does not cause a network request to be blocked but rather
modified before being emitted.

`queryprune` must be assigned a value, which value will
determine which parameters from a query string will be
removed. The syntax for the value is that of regular
expression *except* for the following rules:

- do not wrap the regex directive between `/`
- do not use regex special values `^` and `$`
- do not use literal comma character in the value,
  though you can use hex-encoded version, `\x2c`
- to match the start of a query parameter, prepend `|`
- to match the end of a query parameter, append `|`

`queryprune` regex-like values will be tested against each
key-value parameter pair as `[key]=[value]` string. This
way you can prune according to either the key, the value,
or both.

This commit introduces the concept of modifier filter
options, which as of now are:

- `csp=`
- `queryprune=`

They both work in similar way when used with `important`
option or when used in exception filters. Modifier
options can apply to any network requests, hence the
logger reports the type of the network requests, and no
longer use the modifier as the type, i.e. `csp` filters
are no longer reported as requests of type `csp`.

Though modifier options can apply to any network requests,
for the time being the `csp=` modifier option still apply
only to top or embedded (frame) documents, just as before.
In some future we may want to apply `csp=` directives to
network requests of type script, to control the behavior
of service workers for example.

A new built-in filter expression has been added to the
logger: "modified", which allow to see all the network
requests which were modified before being emitted. The
translation work for this new option will be available
in a future commit.
2020-10-31 10:42:53 -04:00
Raymond Hill
ba2ef925e9
Fix incorrect reset value
This could cause spurious error messages in dev console of
content page.
2020-10-31 10:18:42 -04:00
Raymond Hill
2b88c8b545
Fix incorrect count in built-in benchmark 2020-10-29 06:01:04 -04:00
Raymond Hill
a1aa9bd54f
Disable button until benchmark session is completed 2020-10-27 13:07:05 -04:00
Raymond Hill
4059a92838
Fine tune built-in benchmark
Additionally, add a button in the About pane
to launch benchmark sessions. The button will
be available only when advanced setting
`benchmarkDatasetURL` is set and pointing to
a valid dataset.
2020-10-27 12:59:31 -04:00
Raymond Hill
0bbf5b52ab
Improve token extraction from regex-based filters 2020-10-25 13:06:26 -04:00
Raymond Hill
ed2ad57dca
Ensure no-large-element styling is removed 2020-10-25 08:05:26 -04:00
Raymond Hill
a1a008098c
More fine tuning of no-large-media-elements content script
Related issue:
- https://github.com/gorhill/uBlock/issues/1390
2020-10-23 07:29:14 -04:00
Raymond Hill
2b5a853d8c
Fix regex to validate URL of imported lists
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1306
2020-10-23 06:25:08 -04:00
Raymond Hill
37b195f61d
Remove all event handlers from no-large-media-elements content scripts
Related issue:
- https://github.com/gorhill/uBlock/issues/1390
2020-10-22 09:01:59 -04:00
Raymond Hill
0628d2ec9f
Improve interactivity of no-large-media-elements content scripts
Related issue:
- https://github.com/gorhill/uBlock/issues/1390#issuecomment-713174183
2020-10-22 08:44:55 -04:00
Raymond Hill
b75758808e
Ensure the bottom of dashboard panes is visible
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1304

On small displays, not being able to scroll down
could become a usability issue.
2020-10-21 12:50:24 -04:00
Raymond Hill
ee059540f7
Cache element picker's optimized candidates for reuse
Optimized candidates computed for each depth are now
cached for reuse. This reduces the amount of work
done when moving the depth slider.
2020-10-20 05:37:07 -04:00
Raymond Hill
3ef41e1d78
Exclude cached resources from large-media-element blocking
Related feedback:
- https://github.com/gorhill/uBlock/issues/1390#issuecomment-187310719
2020-10-19 08:01:03 -04:00
Raymond Hill
927d55134d
Remove discarding of assumed unoptimal selectors
This was a bad idea.

Related commit:
- 4c5197322f
2020-10-18 11:06:40 -04:00
Raymond Hill
53dd339d78
Improve interactivity for blocked large media elements
Related issues:
- https://github.com/gorhill/uBlock/issues/1390
- https://github.com/gorhill/uBlock/issues/2334

The deadline to interactively load a specific media
element has been extended from 2sec to 5sec.

Clicking over a blocked large media element will cause
uBO to lookup and handle all potentially blocked large
elements at the cursor position. This should take care
of being able to unblock media elements hidden under
other DOM object.

The CSS style applied to blocked large media elements
has been fine tuned to improve interactivity.

uBO will now remember the specific media elements which
were unblocked and keep them exempted from being
further blocked. This would be an issue when unblocking
a video and then a bit later seeking to another point
in the video, in which case uBO would again block
network requests for that video.
2020-10-18 10:07:46 -04:00
Raymond Hill
9947fcf4d5
Improve layout of popup panel when rendered in a tab
This brings back the ability to screenshot the whole
list of domains when the popup panel is opened in a
tab.
2020-10-18 10:00:55 -04:00
Raymond Hill
6a10319f21
Fix broken advanced property uiStyles
Related commit:
- e3a6d8465f
2020-10-17 12:05:03 -04:00
Raymond Hill
32b08dc732
Mind whitespaces when double-clicking to select filter option value 2020-10-16 17:13:55 -04:00
Raymond Hill
4c5197322f
Improve specificity slider in element picker
The specificity slider will now be more intuitive
by ordering candidates by match count from highest
match count to the left to the lowest match count
to the right.

Candidates with same match counts will be discarded
and replaced with the shortest candidate.
2020-10-16 17:12:22 -04:00
Raymond Hill
38e1bbbe68
Better word selection for static network filters
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1134

Double-clicking on...

... a filter option will cause the option to be
wholly selected, including `=[value]` if present;

... a value assigned to a filter option will cause
the value to be wholly selected, except when the
value is a hostname/entity, in which case all the
labels from the cursor position to the right-most
label will be selected.
2020-10-16 10:06:00 -04:00