1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-09-29 14:17:11 +02:00
Commit Graph

2396 Commits

Author SHA1 Message Date
Raymond Hill
4818405cf6
Remove need to pass parser at every compile() call
The compiler instance is already initialized with a
reference to the parser, no need to keep passing the
reference at each call to compile().
2021-08-05 13:30:20 -04:00
Raymond Hill
85c68116bd
Group all compiling-related code into FilterCompiler() class
In the static network filtering engine (snfe), the
compiling-related code was spread across two classes.
This commit makes it so that all the compiling-related
code is in FilterCompiler class, which clear purpose is
to compile raw filters into a form which can be persisted
and later fed to the snfe with no parsing overhead.

To compile raw static network filter, the new approach is:

    snfe.createCompiler(parser);

Then for each single raw filter to compile:

    compiler.compile(parser, writer);

The caller is responsible to keep a reference to the
compiler instance for as long as it is needed. This removes
the need for the clunky code used to keep an instance of
compiler alive in the snfe.

Additionally, snfe.tokenHistograms() has been moved to
benchmarks.js, as it has no dependency on the snfe, it's
just a utility function.
2021-08-04 15:14:48 -04:00
Raymond Hill
5e8f847aeb
Fix regression in cloud storage upload/download
Reported in team discussion

Regression from:
- 22022f636f
2021-08-03 14:03:00 -04:00
Raymond Hill
89c5653bc6
Export the rule-based filtering engines to the nodejs package
The code exported to nodejs package was revised to use modern
JavaScript syntax. A few issues were fixed at the same time.

The exported classes are:
- DynamicHostRuleFiltering
- DynamicURLRuleFiltering
- DynamicSwitchRuleFiltering

These related to the content the of "My rules" pane in the
uBlock Origin extension.
2021-08-03 12:19:25 -04:00
Manish Jethani
6ef74fc21b
Rewrite logical expressions for ESLint (#3801) 2021-08-03 10:59:01 -04:00
Manish Jethani
3ca5e6817d
Fix ESLint indentation warnings (#3800)
* Fix ESLint indentation warnings

* Undo code reformatting within parentheses

* Add exception for logical expressions

* Update array expression rule

* Disable rule for reProceduralOperator assignment

* Fix indentation in static-filtering-parser.js
2021-08-03 10:14:40 -04:00
Manish Jethani
ad69c760fb
Run ESLint during Node.js package generation (#3798) 2021-08-02 16:55:03 -04:00
Raymond Hill
f8daea085b
Remove assets dependency from redirect engine
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1664

This change allows to add the redirect engine into the
nodejs package. The purpose of the redirect engine is to
resolve a redirect token into a path to a local resource,
to be used by the caller as wished.
2021-08-02 09:23:48 -04:00
vt
2b9aba2748 Handle invalid meta refresh URLs in noscript scriptlet
Invalid URLs like "http://" and "http://foo@" trigger TypeErrors
when they are passed to the URL constructor. These TypeErrors
caused the scriptlet to stop processing subsequent noscript nodes
due to uncaught exceptions.

These exceptions are now caught to allow all noscript nodes to
be processed.
2021-07-31 13:16:33 -04:00
Raymond Hill
cb72211795
Move orphanizeString() into text-utils module
Another small step toward the goal of reducing dependency
on `µb`.

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

text-iterators module has been renamed text-utils to better
reflect its content.
2021-07-31 08:38:33 -04:00
Raymond Hill
dc08478130
Fix https://github.com/uBlockOrigin/uBlock-issues/issues/1675 2021-07-31 07:15:19 -04:00
Raymond Hill
076a088371
Remove stray async 2021-07-29 17:04:32 -04:00
Raymond Hill
98fc66bb1b
Add support for enabling WASM code paths in NodeJS package
See `test.js` for reference on how to enable WASM code
paths (which are disabled by default).
2021-07-29 16:54:51 -04:00
Raymond Hill
8ef8c5ab2e
Group all benchmarking functions in a separate file
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1664

The various filtering engine benchmarking functions are best
isolated in their own file since they have specific
dependencies that should not be suffered by the filtering
engines.

Additionally, moved decomposeHostname() into uri-utils.js
as it's a hostname-related function required by many
filtering engine cores -- this allows to further reduce
or outright remove dependency on `µb`.
2021-07-29 08:44:15 -04:00
Raymond Hill
62b6826dd5
Further modularize uBO's codebase
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1664

Modularization is a necessary step toward possibly publishing
a more complete nodejs package to allow using uBO's filtering
capabilities outside of the uBO extension.

Additionally, as per feedback, remove undue usage of console
output as per feedback:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1664#issuecomment-888451032
2021-07-28 19:48:38 -04:00
Raymond Hill
22022f636f
Modularize codebase with export/import
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1664

The changes are enough to fulfill the related issue.

A new platform has been added in order to allow for building
a NodeJS package. From the root of the project:

    ./tools/make-nodejs

This will create new uBlock0.nodejs directory in the
./dist/build directory, which is a valid NodeJS package.

From the root of the package, you can try:

    node test

This will instantiate a static network filtering engine,
populated by easylist and easyprivacy, which can be used
to match network requests by filling the appropriate
filtering context object.

The test.js file contains code which is typical example
of usage of the package.

Limitations: the NodeJS package can't execute the WASM
versions of the code since the WASM module requires the
use of fetch(), which is not available in NodeJS.

This is a first pass at modularizing the codebase, and
while at it a number of opportunistic small rewrites
have also been made.

This commit requires the minimum supported version for
Chromium and Firefox be raised to 61 and 60 respectively.
2021-07-27 17:26:04 -04:00
Raymond Hill
89064478dd
Modernize code: URLSearchParams() API support is now widespread 2021-07-25 07:08:03 -04:00
Raymond Hill
c25938f5bc
Ensure compiled sections are ordered in ascending id
Related issue:
- https://www.reddit.com/r/uBlockOrigin/comments/oq6kt5/ubo_loads_generic_filter_instead_of_specific/h6a4nca/
2021-07-24 07:44:26 -04:00
Raymond Hill
51d14de44a
Fix handling of some procedural cosmetic filters with explicit :scope
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1011#issuecomment-884806241
2021-07-23 10:11:07 -04:00
Raymond Hill
cd237ed3e1
Fix rendering of punycoded hostname in popup panel
Regression from:
- 75deadd31e
2021-07-20 11:22:33 -04:00
Raymond Hill
75deadd31e
Provide visual cue in popup panel when base domain has subdomains
Related issue:
- https://github.com/gorhill/uBlock/issues/284
2021-07-20 08:37:05 -04:00
Raymond Hill
e85c6f2d3e
Merge background changes to user filters in "My filters" pane
Related issue:
- https://github.com/gorhill/uBlock/issues/3704
2021-07-17 12:03:56 -04:00
Raymond Hill
e3f8a612f4
Minor code review 2021-07-16 14:06:59 -04:00
Raymond Hill
ec7db30b2f
Simplify fetching title of tabs
The title of tabs in uBO is solely to have a better
presentation in the logger -- no other purpose.

This commit simplify keeping track of the titles, from
an active approach by directly querying it from tabs
whenever a change occurs, to a passive approach by
storing it when the title string become available in
some tab event handlers.
2021-07-16 08:59:30 -04:00
Raymond Hill
bbdb68a2b6
Synthesize missing expected onCreatedNavigationTarget events
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1659

This commit introduces a workaround for missing
onCreatedNavigationTarget() in Chromium.
2021-07-15 11:34:37 -04:00
Raymond Hill
e03bb99f57
Add neutered replacement script for mixpanel
Related discussion:
- https://www.reddit.com/r/uBlockOrigin/comments/oicch9/

The new replacement script contains the smallest API
possible to resolve the reported case.

Please report instances where it's not sufficient to
unbreak a site, in which case I will extend the neutered
API to address these cases on an on-demand basis.
2021-07-13 07:58:31 -04:00
Raymond Hill
9a60573abe
Fix broken "Block element..." case when cosmetic filtering is off
Related feedback:
- e983f9a76e (commitcomment-53382148)
2021-07-12 18:32:32 -04:00
Raymond Hill
e983f9a76e
Disable creation of cosmetic filters in picker when unenforceable
Related issue:
- https://github.com/gorhill/uBlock/issues/3212

The element picker will now properly work on sites where
cosmetic filtering is disabled, but will not allow the
creation of cosmetic filters when specific cosmetic filters
are not meant to be enforced in the current page.

When specific cosmetic filters are not meant to be enforced,
the element picker will still allow the creation of network
filters, that is unless the current page is trusted, in which
case using the element picker is pointless.
2021-07-12 11:55:58 -04:00
Raymond Hill
f1a453d349
Avoid pointless check of doc id, presence of doc origin is what matter
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1657
2021-07-12 11:26:25 -04:00
Raymond Hill
717d8593c5
Improve the logger accuracy regarding matched part of the URL
Related issue:
- https://github.com/gorhill/uBlock/issues/3037

This takes care of the specific case reported. There are
other edge cases which are likely not addressed though, i.e.
those involving wildcards -- those should be rather rare and
at this point I rather leave them unaddressed to not
risk regressions (as they are less trivial to address).
2021-07-11 10:11:26 -04:00
Raymond Hill
27c633e054
Better handle negated behhvior types
Related issue:
- https://github.com/gorhill/uBlock/issues/2385
2021-07-10 16:35:52 -04:00
Raymond Hill
ed5dd0a791
Use location.replace() to modify URL of embedded frame
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1648
2021-07-10 09:56:36 -04:00
Raymond Hill
b75921c2fd
Limit recursion when parsing URL in document-blocked page
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1649
2021-07-06 10:13:50 -04:00
Raymond Hill
4422c42788
Discard network filters containing invalid pattern characters
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1146
2021-06-26 12:12:25 -04:00
Raymond Hill
b41463d437
Skip handling non-media elements 2021-06-25 07:24:00 -04:00
Raymond Hill
163035dc92
Drop the v from build version 2021-06-25 07:18:11 -04:00
Raymond Hill
14076fe8c0
Take care of misreporting spurious filter syntax error
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1596
2021-06-24 11:48:27 -04:00
Raymond Hill
81521256e7
Exclude trusted sites from no-popups-switch
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1616
2021-06-24 11:02:06 -04:00
Raymond Hill
ad15a5dd51
Map csp_report to other
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1622
2021-06-24 08:09:18 -04:00
Raymond Hill
090614dd18
Use firstElementChild instead of childElementCount
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1620

Related bugzilla issue:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1715841
2021-06-17 09:58:18 -04:00
Raymond Hill
8877ea290e
Do not redirect when no query parameters are removed
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1626
2021-06-12 13:26:21 -04:00
Raymond Hill
32bd47f053
Force restart at first install for Chromium-based browsers
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1547

The approach used to fix the issue was confirmed working
in the following related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1608#issuecomment-856282345
2021-06-12 09:18:56 -04:00
Raymond Hill
eb519b2ec1
Ensure version changes are persisted at launch 2021-06-02 07:07:10 -04:00
Raymond Hill
37ad821018
Fix loss of newlines when processing pre-parsing directives
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1603
2021-05-26 07:51:10 -04:00
Raymond Hill
7508700892
Prevent unchecked default lists from being visually collapsed
Related issue:
- https://github.com/gorhill/uBlock/issues/2303
2021-05-19 09:34:46 -04:00
Raymond Hill
8cd2a1d263
Make googletagmanager_gtm.js an alias of google-analytics_analytics.js
Related feedback:
- https://ilakovac.com/teespring-ublock-issue/

The surrogate script googletagmanager_gtm.js was essentially a
subset of surrogate script google-analytics_analytics.js. This
commit makes it a plain alias so that the whole GA API -- often
expected by clients of GTM -- is properly stubbed.
2021-05-18 11:08:20 -04:00
Raymond Hill
3fa7316062
Minor code review
Related commit:
- a24e2a5d6c
2021-05-16 08:16:13 -04:00
Raymond Hill
a24e2a5d6c
Fix management of reload button in popup panel
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1461
2021-05-15 10:45:31 -04:00
Raymond Hill
001094580c
Allow filter list subscription through context menu
Related issue/feedback:
- https://github.com/uBlockOrigin/uBlock-issues/issues/763#issuecomment-841582704
2021-05-15 08:15:57 -04:00
Raymond Hill
d0e4c60f59
Keep reporting last time "out of date" lists were updated 2021-05-09 11:53:26 -04:00