1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-09-30 14:47:12 +02:00
Commit Graph

2863 Commits

Author SHA1 Message Date
Raymond Hill
75abf77e62
Fix patching {{args}} when instances of $ are present
Related feedback:
- https://github.com/uBlockOrigin/uAssets/issues/16715#issuecomment-1484232457
2023-03-27 09:04:35 -04:00
Raymond Hill
f7f776fb8a
Aggressively update assets when at least one is very obsolete
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1165
2023-03-26 20:32:51 -04:00
Raymond Hill
a8a46c4593
Normalize non-ASCII characters in :matches-path() argument
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2369
2023-03-26 15:37:15 -04:00
Raymond Hill
da672d4dbf
Add extra check to detect function declaration in scriptlets
Related feedback:
- https://www.reddit.com/r/uBlockOrigin/comments/122pqyg/
2023-03-26 13:14:00 -04:00
Raymond Hill
5c9c87e485
Add ability for scriptlets to share local data
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1741

As a result of the new capability, usage of RegExp API in `aost`
scriptlet has been shielded from the webpage tampering with the
API.
2023-03-26 12:31:36 -04:00
Raymond Hill
236fb3ad59
Add scriptlet dependencies to reduce code duplication 2023-03-26 09:13:17 -04:00
Raymond Hill
a42374199e
Fix regression in parsing scriptlet arguments
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2557
2023-03-24 15:57:48 -04:00
Raymond Hill
18a84d2819
Refactor scriptlets injection code
Builtin scriptlets are no longer parsed as text-based resources,
they are imported as JS functions, and `toString()` is used to
obtain text-based representation of a scriptlet.

Scriptlet parameters are now passed as function call arguments
rather than by replacing text-based occurrences of `{{i}}`. The
arguments are always string values (see below for exception).

Support for argument as Object has been added. This opens the
door to have scriptlets using named arguments rather than
positional arguments, and hence easier to extend functionality
of existing scriptlets. Example:

    example.com##+js(scriplet, { "prop": "adblock", "value": false, "log": true })

Compatibility with user-provided scriptlets has been preserved.

User-provided scriptlets can benefit some of the changes:

Use the form `function(..){..}` instead of `(function(..){..})();`
in order to received scriptlet arguments as part of function call
-- instead of using `{{i}}`.

If using the form `function(..){..}`, you can choose to receive
an Object as argument -- just be sure that your scriptlet's
parameter is valid JSON notation.
2023-03-24 14:05:18 -04:00
Raymond Hill
56b8201196
Ensure astSelectorsFromSelectorList receive expected arguments
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2554
2023-03-23 14:57:31 -04:00
Raymond Hill
2cd062898c
Properly handle default list status changes in assets.json
This commit fix properly handling toggling off the default
status of a list such that the list will be automatically
turned off when its status change from default to non-default.

Additionally, imported lists which become stock lists will
be properly migrated from imported lists section.
2023-03-23 13:40:51 -04:00
Raymond Hill
72cc9a8fe8
Fix broken http header filtering
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2552
2023-03-21 10:22:32 -04:00
Raymond Hill
e8abd5dfbe
Fix report of unprocessed requests in Support pane 2023-03-18 16:20:40 -04:00
Raymond Hill
d42e9ae2a8
Add dev console boot sequence info 2023-03-18 14:37:49 -04:00
Raymond Hill
a9c7369340
Minor fine tuning 2023-03-16 14:54:45 -04:00
Raymond Hill
fd9bb02aab
Fix search widget when swapping document in new code viewer 2023-03-16 12:36:02 -04:00
Raymond Hill
5c92d95143
Prevent dashboard from loading at browser launch until ready
Related discussion:
- https://github.com/uBlockOrigin/uAssets/discussions/16939

Various feedback of people trying to interact with uBO's dashboard
at browser launch, before uBO's main process is fully initialized,
causing confusion, and potential loss of data.
2023-03-16 09:17:36 -04:00
Raymond Hill
39cac612c2
Use the warning toolbar icon only if unprocessed requests
Related discussion:
- https://github.com/uBlockOrigin/uAssets/discussions/16939

Related commit:
- 0c9576d3e6
2023-03-15 21:13:28 -04:00
Raymond Hill
8e35aa74f0
Report only launch-time value of maxAssetCacheWait 2023-03-15 08:32:56 -04:00
Raymond Hill
464b54bbc6
Add ext_devbuild as preparser directive
In order to be able to create filters which only work with the
dev build of uBO.
2023-03-14 19:11:29 -04:00
Raymond Hill
c0529307fa
Properly handle failed fetches in code viewer 2023-03-14 08:58:52 -04:00
Raymond Hill
6ba758d007
Add button to code viewer to reload code from server 2023-03-14 08:43:23 -04:00
Raymond Hill
6220c4d9d5
Improve code viewer convenience
- Retain cursor position, selection, undo history, etc. when swapping
  documents.
- Add ability to remove a document from dropdown list
2023-03-13 10:51:55 -04:00
Raymond Hill
4bf3fe7b5b
Fix minor details in new code viewer
- Automatically remove quotes around URLs pasted in input field
- Fix editor not getting the focus after interacting with input
  field
2023-03-12 17:47:21 -04:00
Raymond Hill
caeb848c56
Fix race condition when looking up current auto/light/dark theme
Related feedback:
- e2dd008388 (commitcomment-104105757)
2023-03-12 11:20:54 -04:00
Raymond Hill
7b632b32a8
Fix "View source..." context menu entry in Firefox 2023-03-12 10:21:30 -04:00
Raymond Hill
4b6ce5e402
Cleanup unused code
Related discussion:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1529
- https://github.com/uBlockOrigin/uBlock-issues/discussions/1958#discussioncomment-5257148
2023-03-12 10:08:20 -04:00
Raymond Hill
b63ced24d4
Fix broken filter parsing when prepended with spaces
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2540
2023-03-12 09:45:33 -04:00
Raymond Hill
e2dd008388
Add 'View source...' entry in context menu
This new context menu entry will be available only when the
advanced setting `filterAuthorMode` is set to `true`. See:

https://github.com/gorhill/uBlock/wiki/Advanced-settings#filterauthormode

The purpose is for filter list maintainers to easily access
the source code of web pages when investigating filter issues,
without having to necessarily go through the logger.

Additionally an input field to enter URL directly has been
added to the code viewer for convenience.
2023-03-11 15:55:51 -05:00
Raymond Hill
7bfa8f260b
Just select already existing tab when opening link from logger 2023-03-11 09:40:34 -05:00
Raymond Hill
574f30ed43
Context of about:blank is that of parent frame (popup option)
Related feedback:
- https://github.com/uBlockOrigin/uBlock-issues/discussions/2534#discussioncomment-5264792
2023-03-10 08:48:48 -05:00
Raymond Hill
3c4c3767a2
Report filter list of invalid filter in logger
Related feedback:
- https://github.com/uBlockOrigin/uBlock-issues/discussions/2534
2023-03-10 06:48:57 -05:00
Raymond Hill
890aabaae9
Make parser take into account filterOnHeaders setting
Related feedback:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1134#issuecomment-1460638431
2023-03-08 13:49:21 -05:00
Raymond Hill
bbd9470a98
Convert resource URLs into clickable links in code viewer 2023-03-08 12:31:39 -05:00
Raymond Hill
f9b03ebeac
Report unprocessed network request count in troubleshooting info
Related discussion:
- https://github.com/uBlockOrigin/uAssets/discussions/16939
2023-03-08 09:36:09 -05:00
Raymond Hill
0c9576d3e6
Show a distinct toolbar icon until filtering engines are fully initialized
Related discussion:
- https://github.com/uBlockOrigin/uAssets/discussions/16939

Until uBO's filtering engines are properly initialized, there will
be a distinct toolbar icon to help users understand that uBO may
not be fully initialized when a webpage is loaded -- often the
cause of improper filtering of trackers/ads at browser launch.
2023-03-07 16:02:09 -05:00
Raymond Hill
bd84a7c8d5
Support rendering xhr requests in new code viewer
Related commit:
- 33c437f99f
2023-03-07 13:40:52 -05:00
Raymond Hill
a0a23085ed
Do not generate DNR block rule for redirect= filters
DNR API does not support block-then-redirect concept, hence no
point in generating a DNR block rule for `redirect=` filters.

Additionally, better handle orphaned filter anchors (`||`, `|`).
2023-03-06 13:06:57 -05:00
Raymond Hill
cd21a0bb9d
MV3 implicit Rule priority is 1, not 0
Related issue:
- https://github.com/uBlockOrigin/uBOL-issues/issues/30
2023-03-03 16:52:28 -05:00
Raymond Hill
82c73199e4
Simplify parser's templating code 2023-03-03 13:49:58 -05:00
Raymond Hill
033aa9cfad
Need valid tab id for scriptlet injection 2023-03-03 12:14:36 -05:00
Raymond Hill
a60a5c2772
Fix wrong syntax color highlight in "Trusted sites" pane
Related feedback:
- https://github.com/uBlockOrigin/uBlock-issues/discussions/2521
2023-03-02 20:50:32 -05:00
Raymond Hill
4ef6420f7c
Fine tune new code viewer
Remove read-only restriction -- it might be useful to
enter notes/markers/etc when investigation code flow.
2023-03-02 17:11:40 -05:00
Raymond Hill
138e6bc37f
Remove obsolete comment 2023-03-01 12:31:44 -05:00
Raymond Hill
33c437f99f
Add source code viewer (from logger)
This commits add the ability to open html/css/script
resources from the logger, as a formatted and syntax-
highligthed document.

The goal is to make it easier for filter list authors to
investigate filter-related issues.
2023-03-01 11:04:40 -05:00
Raymond Hill
db118483c9
Support update period below 1-day
Related feedback:
- https://www.reddit.com/r/uBlockOrigin/comments/11bfwgn/how_to_update_custom_filter_lists_automatically/ja280xu/
2023-03-01 05:26:30 -05:00
Raymond Hill
8f32bee8b9
Restore behind-the-scene origin for docless secondary resources
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2515
2023-02-28 20:08:31 -05:00
Raymond Hill
09bc4e21c7
Refine AST template's regex for hosts file entries
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2512
2023-02-27 09:07:38 -05:00
Raymond Hill
454a03a98f
Use block scope to isolate context 2023-02-24 18:02:28 -05:00
Raymond Hill
191f2f00d6
Put back reload button in logger's "Details" dialog
Related feedback:
- https://github.com/uBlockOrigin/uBlock-issues/discussions/2497#discussioncomment-5100726
2023-02-24 18:00:16 -05:00
Raymond Hill
d8bc7436e8
Flush cached result when adding to FilterDomainHitSet
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2507
2023-02-22 10:21:20 -05:00
Raymond Hill
e740068691
Support moving logger dialog around with touch events
Related feedback:
- https://github.com/uBlockOrigin/uBlock-issues/discussions/2497
2023-02-19 18:41:57 -05:00
Raymond Hill
c8c5264aca
Fix improper invalidation of inline-(font|script) types
Related feedback:
- https://www.reddit.com/r/uBlockOrigin/comments/1132loz/
2023-02-15 16:40:59 -05:00
Raymond Hill
10e680c2ef
Output highly generic cosmetic filters 2023-02-13 12:43:58 -05:00
Raymond Hill
8f2e7ae202
Prevent context menu entries on non-HTTP documents
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1093#issuecomment-1423342620
2023-02-08 19:35:15 -05:00
Raymond Hill
ac25b2d6f3
Fix regression of exception procedural cosmetic filters
Related feedback/commit:
- bc19a93815 (commitcomment-99271464)
2023-02-04 08:21:17 -05:00
Raymond Hill
fe5fdfe5ed
Use precomputed AST layouts to speed up parsing
Related commit:
- 99ac234d12
2023-02-02 12:14:56 -05:00
Raymond Hill
bc19a93815
Ignore compilation hints when applying exception cosmetic filters
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2475
2023-02-01 11:24:07 -05:00
Raymond Hill
6eec497ae8
Minor code review 2023-02-01 10:22:13 -05:00
Raymond Hill
7881e1ace3
Fix bad cut-n-paste piece of code
Related commit:
- b1de8d3fe4
2023-02-01 09:16:58 -05:00
Raymond Hill
81498474d6
Add support for regex-based values as target domain for static extended filters
Related discussion:
- https://github.com/uBlockOrigin/uBlock-issues/discussions/2234

Example of usage:

    /img[a-z]{3,5}\.buzz/##+js(nowoif)

Use sparingly, when no other solution is practical from a maintenance point
of view -- keeping in mind that uBO has to iterate through all the regex-based
values, unlike plain hosyname or entity-based values which are mere lookups.

Related commit:
- b1de8d3fe4
2023-01-31 14:15:13 -05:00
Raymond Hill
d2487b6a6d
Remove unused interestCohort-related code paths
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1553
2023-01-31 09:51:43 -05:00
Raymond Hill
b1de8d3fe4
Add support for regex-based values for domain=/from=/to= options
Related discussion:
- https://github.com/uBlockOrigin/uBlock-issues/discussions/2234

Example of usage:

    @@*$ghide,domain=/img[a-z]{3,5}\.buzz/

Regex-based domain values can be negated just like plain or
entity-based values:

    *$domain=~/regex.../

This new syntax does not apply to static extended filters.
2023-01-30 17:00:26 -05:00
Raymond Hill
d88ec51b63
Minor code review 2023-01-30 11:14:07 -05:00
Raymond Hill
2e1cb9be9b
Ensure pattern is first unit for biditrie-ability purpose 2023-01-30 11:12:21 -05:00
Raymond Hill
c54b521345
Minor code review 2023-01-30 11:11:56 -05:00
Raymond Hill
70e2864ca4
Fix broken parser involving specific filters with Unicode characters
Related feedback:
- https://www.reddit.com/r/uBlockOrigin/comments/10obivd/

The issue was arising with filters of the form:

    ||example.org^$domain=[domain name with Unicode characters]
2023-01-29 16:13:43 -05:00
Raymond Hill
6fd58c9c9b
Fix improper partiness attribution for some delayed network requests
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2453
2023-01-28 11:38:53 -05:00
Raymond Hill
99ac234d12
Add fast code paths for frequent filter patterns
Related commit:
- 8ea3b0f64c
2023-01-28 08:44:54 -05:00
Raymond Hill
26e8771256
Fix filure to lookup filters with header= option
Related feedback:
- bde3164eb4 (commitcomment-98348215)
2023-01-27 20:18:20 -05:00
Raymond Hill
827f0e4971
Do not disallow using inline-script with real network types
Related feedback:
- https://www.reddit.com/r/uBlockOrigin/comments/10l2jjr/help_latest_ubo_developer_version_is_not_working/j5wdjjv/
2023-01-26 10:12:59 -05:00
Raymond Hill
c600cbbd3a
Fix severe regression causing infinite loop in new parser
Related feedback:
- https://www.reddit.com/r/uBlockOrigin/comments/10l2jjr/help_latest_ubo_developer_version_is_not_working/
- https://github.com/uBlockOrigin/uBlock-issues/issues/2469
2023-01-25 18:05:06 -05:00
Raymond Hill
ccdf6bd150
Fix generating NODE_TYPE_EXT_PATTERN_SCRIPTLET branch
Related feedback:
- 8ea3b0f64c (commitcomment-97858269)
2023-01-24 08:07:30 -05:00
Raymond Hill
8ea3b0f64c
Rewrite static filtering parser
This commit is a rewrite of the static filtering parser into a
tree-based data structure, for easier maintenance and better
abstraction of parsed filters.

This simplifies greatly syntax coloring of filters and also
simplify extending filter syntax.

The minimum version of Chromium-based browsers has been raised
to version 73 because of usage of String.matchAll().
2023-01-23 16:53:18 -05:00
Raymond Hill
4564e3a9b8
Add redirectable resource noop.css, as suggested
Related feedback:
- https://github.com/uBlockOrigin/uAssets/issues/16391#issuecomment-1396316194
2023-01-23 16:39:46 -05:00
Raymond Hill
c5baa8808b
Minor code review 2023-01-07 12:55:57 -05:00
Raymond Hill
789ee8d910
Minor code review 2023-01-07 12:52:46 -05:00
Raymond Hill
2b5efe9dcb
Improve plain CSS validation in cosmetic filters
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2442

Cosmetic filters with unknown plain CSS pseudo-classes or
unknown plain CSS pseudo-elements will be rejected, except
for pseudo-classes/pseudo-elements which start with a `-`.
2023-01-07 10:13:51 -05:00
Raymond Hill
988a352cc4
Fine tuning the logger's entry tools positioning
Related feedback:
- https://www.reddit.com/r/uBlockOrigin/comments/10483e5/new_logger_functions_in_latest_dev_build_ubo/j33tx0y/
2023-01-06 10:16:24 -05:00
Raymond Hill
d9b50fcd51
Drop as invalid unknown argument-based pseudoclass operators
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2442

These invalid pseudoclass operators were still seen as
valid when mixed with procedural pseudoclass operators.
2023-01-06 09:54:11 -05:00
Raymond Hill
7847731e9a
Remember position entry tools widget in logger
Related feedback:
- a9405fe36c (commitcomment-95164238)
2023-01-05 12:49:02 -05:00
Raymond Hill
5e45c7249a
Add more columns in logger for bringing up entry details 2023-01-05 09:08:26 -05:00
Raymond Hill
7b8c096270
Better validate :upward() argument
Related feedback:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2442#issuecomment-1371484554
2023-01-05 08:39:31 -05:00
Raymond Hill
a9405fe36c
Make the logger entry dialog modeless 2023-01-04 13:43:12 -05:00
Raymond Hill
dfe9d3a1da
Fix missing regex flags
Related feedback:
- https://www.reddit.com/r/uBlockOrigin/comments/1005a8f/suddenly_my_filters_doesnt_work/j2htwof/
2023-01-01 21:58:14 -05:00
Raymond Hill
f8d2bd0ebb
Set charset to utf-8 for Blob-based injected scriptlets
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2431
2023-01-01 09:33:20 -05:00
Raymond Hill
72dabcac66
Disallow -abp-... filters if not using #?#
Related feedback:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2435#issuecomment-1367805459
2023-01-01 09:20:32 -05:00
Raymond Hill
3f71659aa8
Work related to keyboard shortcuts for page reload
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/896

Additionally, added the keyboard shortcuts to reload the current
tab to the logger. This changes the prior behavior of reloading
the logger content itself.
2022-12-25 10:34:53 -05:00
Raymond Hill
4157171b7f
Use "constant" property for target hntrie container 2022-12-25 08:54:18 -05:00
Raymond Hill
6a50f41aeb
Internal cell count !== visual cell count
Internal cell count is used to filter the output of the logger. This
commit fixes filtering according to cname alias.
2022-12-24 10:30:25 -05:00
Raymond Hill
b194baa089
Fix visual regressions in logger
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2425
2022-12-24 10:04:31 -05:00
Raymond Hill
d5f9c05d62
Take method= into account when evaluating whether a filter is pure hostname
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2117
2022-12-24 09:49:46 -05:00
Raymond Hill
19f8b30d57
New network filter option: to=[list of domain names]
Related discussion:
- https://github.com/uBlockOrigin/uBlock-issues/discussions/2412#discussioncomment-4421741

The new option is `to=` and the value is a list of domain list with
similar syntax as `domain=` option. Entity-based syntax is supported,
and also negated hostname.

The main motivation is to give uBO's static network filtering engine
with an equivalent of DNR's `requestDomains` and `excludedRequestDomains`.

Essentially `to=` is a superset of `denyallow=`, but for now I decided
against deprecating `denyallow=`, which still does not support entity-
based syntax and for which negated domains are not allowed.

This commit also introduces the `from=` option, which is just an alias
for the `domain=` option. The logger will render network filters using
the `from=` version.
2022-12-23 15:52:24 -05:00
Raymond Hill
b6981877ba
Add option to filter by HTTP method in static network filters
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2117

Option: `method=`
Value: a list of `|`-separated lowercased method names. Negated
method names are allowed. These are valid methods:

- connect
- delete
- get
- head
- options
- patch
- post
- put

As per DNR's own documentation:
- https://developer.chrome.com/docs/extensions/reference/declarativeNetRequest/#type-RequestMethod

The logger shows the method used for every network request. It's
possible to filter the logger output for most-common methods: `get`,
`head`, `post`.
2022-12-22 13:15:08 -05:00
Raymond Hill
3fe6846da7
Fix case-sensitiveness in :has-text() (regression)
Related feedback:
- https://www.reddit.com/r/uBlockOrigin/comments/zqot4i/is_there_a_way_to_show_only_element_with_specific/j0zl4ck/
2022-12-20 14:34:54 -05:00
Raymond Hill
f78fb513a1
Support generic exception filter for HTML filtering
Related feedback:
- fa5e4b7769 (commitcomment-93202819)
2022-12-15 11:35:03 -05:00
Raymond Hill
a31f74325d
Fix "make lint" errors 2022-12-15 11:20:52 -05:00
Raymond Hill
fa5e4b7769
Fine tune new exceptor code
Related feedback:
- a91781a495 (commitcomment-93128519)

For instance, do not make exceptor widget available for
exceptions from filter lists.
2022-12-15 10:04:59 -05:00
Raymond Hill
a91781a495
Rewrite logger's "exceptor" feature
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1861

The "exceptor" feature has been rewritten, with the following
changes as a result:

- The excepted filters cease to exist when closing the logger
- It's now possible to temporary except network filters

When toggling on/off a temporary exception, filter lists are now
fully reloaded. This simplified managing temporary exceptions, and
made it easy to implement temporary exception for network filters,
but this also means there might be a perceptible delay when
adding/removing temporary exceptions. At this point I consider
this an acceptable side-effect just to bring the ability to easily
create temporary exception for network filters, while this
simplified the existing temporary exception code throughout.
2022-12-14 16:04:45 -05:00
Raymond Hill
d77331f73a
Be sure procedural filterer is present before use
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2407
2022-12-14 08:56:04 -05:00
Raymond Hill
b603e9e81e
Various code review related to extended filtering
Bring latest changes to procedural cosmetic filtering to uBOL.

Fix procedural filtering used in HTML filters.

Standardize quick hash algorithm used throughout to DJB2
(except that initialization step is skipped):
- http://www.cse.yorku.ca/~oz/hash.html#djb2
2022-12-13 10:23:51 -05:00