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

2745 Commits

Author SHA1 Message Date
Raymond Hill
fca4db8021
Better handle network error when fetching sublist
Reported internally:

> STR --
>
> Import https://cdn.statically.io/gh/uBlockOrigin/uAssets/master/filters/filters.txt
> as a Custom filter list.
>
> Observe the filter count at 24K instead of true count
> being 29K.
>
> Force updating is sometimes compiling 24K filters and
> on subsequent updates 29K, so I narrowed it down to
> this host.

Findings:

One of the sublists was erroring when being fetched on
this particular CDN server (reason unknown).

uBO was not properly handling network errors when
fetching a sublist. This commit make it so that if
a sublist can't be fetched, then the error is propagated
as if it affected the whole list, in which case uBO will
use an alternative URL if any.
2021-04-29 08:32:32 -04:00
Raymond Hill
81fadf836f
Stop autoplay for unset media source with no-large-media-elements
Related feedback:
- https://www.reddit.com/r/uBlockOrigin/comments/mxgpmc/
2021-04-27 08:59:59 -04:00
Raymond Hill
2a5e67e3f5
Use CDN URLs as fall back URLs
Related feedback:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1566#issuecomment-826473517

Additionally, add more CDN URLs to default filter lists.
2021-04-27 08:56:07 -04:00
Raymond Hill
912bdce9cd
Normalize removeparam to removeparam, not queryprune 2021-04-16 08:59:57 -04:00
Raymond Hill
bc8c1d00ad
Remove advanced setting ignoreScriptInjectFilters
This advanced setting is not really needed, as the
same can be accomplished with a broad exception
filter such as `#@#+js()`.

Related feedback:
- f5b453fae3 (commitcomment-49499082)
2021-04-14 10:56:04 -04:00
Raymond Hill
58505cfddc
Finalize 3rd-party scripts/frames mini-filtering widget
For now the mini-filtering widget on 3rd-party scripts/frames
cells will allow to emphasize rows which have 3rd-party
scripts and/or frames.

Somewhat related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/210
2021-04-13 09:08:53 -04:00
Raymond Hill
f5b453fae3
Remove advanced setting ignoreScriptInjectFilters
Ever since the `redirect` code was refactored:

157cef6034

This advanced setting is no longer needed, as the same
can be accomplished with a plain network filter:

    @@*$redirect-rule
2021-04-13 08:49:10 -04:00
Raymond Hill
bfdc81e9e4
Ensure FLoC is opt-in by default
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1553

This commit ensures FLoC is opt-in. The generic filter
`*##+js(no-floc)` in "uBlock filters -- Privacy" ensures
the feature is disabled when using default settings/lists.

Users can opt-in to FLoC by adding a generic exception
filter to their custom filters, `#@#+js(no-floc)`; or they
can opt-in only for a specific set of websites through a
more specific exception filter:

    example.com,shopping.example#@#+js(no-floc)
2021-04-11 09:36:56 -04:00
Raymond Hill
9a94ba0a22
Fix regex used to extract attribute name in element picker
Related feedback:
- https://www.reddit.com/r/uBlockOrigin/comments/mh2ctv/
2021-03-31 12:21:29 -04:00
Raymond Hill
b1228f9d51
Add missing new JS file
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1527#issuecomment-798449462

Related commit:
- f876b68171
2021-03-13 09:38:29 -05:00
Raymond Hill
5e5bc24f63
Alphabetical order 2021-03-13 09:05:54 -05:00
Raymond Hill
f876b68171
Add support for removal of response headers
The syntax to remove response header is a special case
of HTML filtering, whereas the response headers are
targeted, rather than the response body:

  example.com##^responseheader(header-name)

Where `header-name` is the name of the header to
remove, and must always be lowercase.

The removal of response headers can only be applied to
document resources, i.e. main- or sub-frames.

Only a limited set of headers can be targeted for
removal:

  location
  refresh
  report-to
  set-cookie

This limitation is to ensure that uBO never lowers the
security profile of web pages, i.e. we wouldn't want to
remove `content-security-policy`.

Given that the header removal occurs at onHeaderReceived
time, this new ability works for all browsers.

The motivation for this new filtering ability is instance
of website using a `refresh` header to redirect a visitor
to an undesirable destination after a few seconds.
2021-03-13 08:53:34 -05:00
Raymond Hill
a01c03e11a
Fix no-scripting switch not working for SVG-based documents
Issue spotted while trying the following page:
- https://www.xul.fr/svgtetris.svg
2021-03-06 08:18:46 -05:00
Raymond Hill
9f063c717b
Also CSS-escape tag name in element picker
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1519
2021-03-04 06:19:44 -05:00
Raymond Hill
404e6252d6
Fix regression causing exceptions to be thrown
Related commit:
- 1c3b45f75d

Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1513
2021-03-03 10:51:56 -05:00
Raymond Hill
1c3b45f75d
Expose ability to toggle on/off cname-uncloaking to all users
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1513

Prior to this commit, the ability to enable/disable the
uncloaking of canonical names was only available to advanced
users. This commit make it so that the setting can be
toggled from the _Settings_ pane.

The setting is enabled by default. The documentation should
be clear that the setting should not be disabled unless it
actually solves serious network issues, for example:

https://bugzilla.mozilla.org/show_bug.cgi?id=1694404

Also, as a result, the advanced setting `cnameUncloak` is no
longer available from within the advanced settings editor.
2021-03-02 13:00:56 -05:00
Raymond Hill
972feae05d
Drop ctrl-key requirement in "Purge all caches" operation
Related feedback:
- https://www.reddit.com/r/uBlockOrigin/comments/lrcwii/memory_use_in_roaming_profile_in_windows/goq6h4n/
2021-02-26 06:48:26 -05:00
Raymond Hill
b7a2352c6f
Do not suggest network filters with wildcarded hostname in picker
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1494
2021-02-22 07:57:23 -05:00
Raymond Hill
918a073c81
Fix regression in strict blocking
Related feedback:
- https://www.reddit.com/r/uBlockOrigin/comments/lp6dwp/

Regression from:
- 3af1120082
2021-02-22 06:32:43 -05:00
Raymond Hill
266a7507b8
Fix regression when initializing popup panel
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1505

Regression from:
- 435c91636f
2021-02-21 07:41:09 -05:00
Raymond Hill
3565a0511e
Update comment
DOM logger and inspector are loaded on demand.
2021-02-20 07:05:19 -05:00
Raymond Hill
dfa1b64cae
Fix regression when reverting temporary rules in popup panel
Refression from:
- 435c91636f
2021-02-19 12:32:07 -05:00
Raymond Hill
3af1120082
Add support for exception of document to bypass strict-blocking
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1501

Exception filters for `document` option are complying with
uBO's own semantic for `document` option, i.e. an exception
filter for `document` option will only allow to bypass a
block filter for `document` (either explicit or implicit)
and nothing else.

Exception filters using `document` option are *not*
compatible with ABP's interpretation of these filters.
Whereas in ABP the purpose of a `document` exception filter
is to wholly disable content blocking, in uBO the same
filter will just cause strict-blocking to be disabled while
leaving content blocking intact.

Additionally, the logger was fixed to properly report pages
which are being strict-blocked.
2021-02-19 08:38:50 -05:00
Raymond Hill
96049f147e
Reflect latest changes in comment 2021-02-19 08:38:07 -05:00
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
Raymond Hill
a095b83250
Use a CodeMirror editor instance in element picker
This allows to bring in all the benefits of
syntax highlighting and enhanced editing
features in the element picker, like auto-
completion, etc.

This is also a necessary step to possibly solve
the following issue:

- https://github.com/gorhill/uBlock/issues/2035

Additionally, incrementally improved the behavior
of uBO's custom CodeMirror static filtering syntax
mode when double-clicking somewhere in a static
extended filter:

- on a class/id string will cause the whole
  class/id string to be   selected, including the
  prepending `.`/`#`.

- somewhere in a hostname/entity will cause all
  the labels from the cursor position to the
  right-most label to be selected (subject to
  change/fine-tune as per feedback of filter
  list maintainers).

Related feedback:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1134#issuecomment-679421316
2020-10-14 10:21:30 -04:00
Raymond Hill
3da97673d9
Remove more remnants of obsolete pseudo user styles code
Related commit:
- 5c68867b92
2020-10-13 07:19:06 -04:00
Raymond Hill
6e010ecc0f
Prevent set-constant properties from being overtaken
Related feedback:
- https://github.com/uBlockOrigin/uBlock-issues/issues/156#issuecomment-707095193

Additionally, while investigating the issue I removed
code which is no longer needed since content scripts
are now injected in `about:blank` frames since 1.29.0.
2020-10-12 10:08:51 -04:00
Raymond Hill
1727585faa
Hightlight to warn about unknown redirect tokens
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1134
2020-10-11 08:59:44 -04:00
Raymond Hill
6ff72af4aa
Only URLs in comments can be selected through double-click 2020-10-11 07:45:58 -04:00
Raymond Hill
2e5d32e967
Fine tune code related to click-to-load feature
The redirectable resource has been renamed
`click2load.html`, so as to avoid uses of dash
characters and to also allow for future different
click-to-load resources.
2020-10-10 08:36:30 -04:00
Raymond Hill
5916920985
Add support for click-to-load of embedded frames
Additionally, as a requirement to support click-to-load
feature, redirected resources will from now on no
longer be collapsed.

Related issues:
- https://github.com/gorhill/uBlock/issues/2688
- https://github.com/gorhill/uBlock/issues/3619
- https://github.com/gorhill/uBlock/issues/1899

This new feature should considered in its draft
stage and it needs to be fine-tuned as per
feedback.

Important: Only embedded frames can be converted
into click-to-load widgets, as only these can be
properly shieded from access by page content.

Examples of usage:

    ||youtube.com/embed/$3p,frame,redirect=clicktoload
    ||scribd.com/embeds/$3p,frame,redirect=clicktoload
    ||player.vimeo.com/video/$3p,frame,redirect=clicktoload
2020-10-09 13:50:54 -04:00
Raymond Hill
c3f267db8f
Improve bad filter detection in element picker
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1280
2020-10-08 09:49:35 -04:00
Raymond Hill
4f00c08f6b
Fix detection of already present comment
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1281

Related feedback:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1281#issuecomment-705081202
2020-10-07 14:23:57 -04:00
Raymond Hill
46ec969411
Add ability to use full URL in auto-generated comment
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1281

New supported placeholder: `{{url}}`, which will be
replaced by the full URL of the page for which a filter
is created.
2020-10-07 11:52:38 -04:00
Raymond Hill
04b11b4311
Fix restore backup feature
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1282
2020-10-06 21:02:51 -04:00
Raymond Hill
778338fce8
Fix picker generating overly long candidate cosmetic filters
Related feedback:
- https://www.reddit.com/r/uBlockOrigin/comments/j5tx8x/understand_the_element_blocker_and_feedback/g7wf2q9/

Regression from:
- https://github.com/gorhill/uBlock/commit/9eb455ab5eb2
2020-10-06 17:26:28 -04:00
Raymond Hill
57048d57b2
Reject improper use of procedural operator in selector list
Related feedback:
- https://github.com/uBlockOrigin/uBlock-issues/issues/382#issuecomment-703725346
2020-10-06 12:39:05 -04:00
Raymond Hill
aff75b3527
Fix typo breaking the collapsing of placeholders
Related issue:
- https://github.com/gorhill/uBlock/issues/2848
2020-10-05 14:20:43 -04:00
Raymond Hill
d97c46ffd3
Use a user stylesheet to implement the collapsing of placeholders
Related issue:
- https://github.com/gorhill/uBlock/issues/2848
2020-10-05 09:13:07 -04:00
Raymond Hill
f4aebc9390
Backup/restore only modified advanced settings
This reduces the size of the backup file and also
ensures that default values can be changed.
2020-10-03 12:34:21 -04:00
Raymond Hill
e3a6d8465f
Add advanced setting to force a light/dark theme
Related feedback:
- https://github.com/uBlockOrigin/uBlock-issues/issues/401#issuecomment-703075797

Name: `uiTheme`
Default: `unset`
Values:
- `unset`: uBO will pick the theme according to
  browser's `prefers-color-scheme`
- `light`: force light scheme
- `dark`: force dark theme

This advanced setting is not to be documented yet as
it has not been decided this is a long term solution.
2020-10-03 07:13:40 -04:00
Raymond Hill
fef375a594
Minor improvements to syntax highlight of static filters
Double-cliking on a URL will cause the whole URL to be
selected, thus making it easier to navigate to this
URL (through your browser "Open in new tab" entry in
contextual menu).

Unrecognized scriptlet names will be highlighted so as
to warn that the filter is not going to be effective.
2020-09-30 10:01:10 -04:00
Raymond Hill
15e0778750
Prevent spurious instantiation of procedural filterer
Injecting declarative CSS `:style()` selector could cause
the instatiation of the procedural filterer, even when
there was no actual procedural cosmetic filter to
enforce.

This commit ensure that the procedural cosmetic filterer
is instantiated only when there are actual procedural
filters to enforce.
2020-09-24 10:53:18 -04:00
Raymond Hill
5df51d63d1
Do not syntax-highlight ... in "My rules" pane 2020-09-23 11:14:09 -04:00
Raymond Hill
99f605d28a
Minor code review of subscriber scriptlet 2020-09-21 07:25:24 -04:00
Raymond Hill
b3b2fc3b42
Remove unused property 2020-09-20 09:29:17 -04:00
Raymond Hill
6b15e8c423
Fix highlighting of good/bad hostnames in "My rules" pane
Related feedback:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1249#issuecomment-695755743
2020-09-20 08:58:04 -04:00
Raymond Hill
c181ab2911
Fix ability to set temporary cosmetic filter exceptions
Regression from:
- 35aefed926
2020-09-19 10:00:21 -04:00
Raymond Hill
3f299ef623
Improve validation of hostname in domain= and denyallow options
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1249

For "exotic" hostname values, the browser's own API will be
used to ultimately validate hostname values.
2020-09-18 10:23:02 -04:00
Raymond Hill
328d6a09f4
Fix broken styling of selectors with pseudo elements
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/382

Additionally, fix minor parsing issues with AdGuard's
cosmetic filters.
2020-09-14 14:58:25 -04:00
Raymond Hill
fe9797cacc
Add easylist.to as a valid target for subscriber content script 2020-09-14 08:43:51 -04:00
Raymond Hill
714f07dc25
Work around instances of over-encoded subscription URLs
Related feedback:
- https://github.com/uBlockOrigin/uBlock-issues/issues/763#issuecomment-691696716
2020-09-13 13:41:25 -04:00
Raymond Hill
4c7635514a
Fine tuning changes to click-to-subscribe code
Related feedback:
- https://github.com/uBlockOrigin/uBlock-issues/issues/763#issuecomment-691682195

Additionally, enable an existing subscription when
subscribing again to it.
2020-09-13 11:44:42 -04:00
Raymond Hill
e60042595c
Revisit the behavior of the click-to-subscribe content script
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/763

Changes:

From now on, uBO will allow click-to-subscribe on only
a few select domains, currently:
- https://filterlists.com/
- https://github.com/
- https://github.io/

More domains can be added if and only the demonstration
is made that more than a marginal number of filter lists
can be subscribed from those domains.

The browser alert box is no longer used to confirm
subscription to a filter list. Instead, the asset
viewer has been expanded to serve that purpose. This
way, users can peruse at the content of a filter list
before subscribing to it.
2020-09-13 08:01:53 -04:00
Raymond Hill
da7ff2b382
Remove now pointless use of important in CSS styles
Now that the element picker user interface is isolated
frompage content world, there is no need to use the
`important` modifier for the element picker's own
CSS styles.
2020-09-12 11:36:30 -04:00
Raymond Hill
05893a6c16
Fix swipe right to exit zapper/picker on touch displays
Regression from:
- d23f9c6a8b
2020-09-12 11:29:39 -04:00
Raymond Hill
218f774ba0
Fix broken localized string in some languages
Reported as feedback at:
- https://crowdin.com/translate/ublock
2020-09-12 10:37:08 -04:00
Raymond Hill
b73b24ebb1
Fix slider's responsiveness to layout changes
Related commit:
- f01bda1159
2020-09-12 08:26:44 -04:00
Raymond Hill
f01bda1159
Rework visuals of element picker sliders
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/851
2020-09-12 07:28:46 -04:00
Raymond Hill
ead49e083a
Fix delete key handling in element zapper
Related feedback:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1237#issuecomment-690897502
2020-09-11 08:12:45 -04:00
Raymond Hill
f0ef680a86
Remove pointless test for parent node presence
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1240
2020-09-11 07:58:01 -04:00
Raymond Hill
df83a0847f
Forgot to commit last minute changes in element picker
Related commit:
- 260f762c83
2020-09-10 10:40:07 -04:00
Raymond Hill
260f762c83
Add widget to control selector depth to element picker
Further iterating on the work done in following commit:
- 1268f0ae43

This commit adds a new widget to the element picker to
control the depth of a cosmetic filter selector. The
new widget is essentially just another way of selecting
the depth, which is still controllable through picking
one of the cosmetic filters in the list of candidates.
2020-09-10 10:32:53 -04:00
Raymond Hill
6f7801d433
Fix zapper not being able to remove SVG elements
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1237
2020-09-09 10:51:30 -04:00
Raymond Hill
d4182add6e
Add ability to outright remove/ignore "really bad lists"
In addition to what is deemed really bad lists by consensus,
some lists will also be labelled "really bad list"
temporarily so as to force-remove them from the set of
filter lists.

This will be the case for filter lists which are not
necessarily "bad lists" but which were once part of
uBO's stock filter lists and have been removed since
then for various reasons.

This will ensure that the majority of users who do not
modifies uBO's default listset will still have a
configuration which matches the official default listset.
2020-09-09 09:57:29 -04:00
Raymond Hill
1268f0ae43
Add element picker widget to control specificity
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/851

The ctrl key is no longer used to adjust specificity of
a candidate filter.

A new widget has been added to adjust the specificity of
a candidate filter to various level. The widget will be
visible as long as the candidate filter matches one entry
in the list of suggested candidate cosmetic filters.
2020-09-09 09:27:53 -04:00
Raymond Hill
35aefed926
Add support to chain :style() to procedural operators
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/382

Additionally, remnant code for pseudo-user stylesheets
has been removed. Related commit:
- 5c68867b92
2020-09-07 08:28:01 -04:00
Raymond Hill
4ce3ff2e04
Remove code for unused message 2020-09-03 10:56:29 -04:00
Raymond Hill
d23f9c6a8b
Isolate element picker's svg layers from page content
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1226

Related commit:
- 9eb455ab5e

In the previous commit, the element picker dialog was
isolated from the page content. This commit is to also
isolate the svg layers from the page content.

With this commit, there is no longer a need for an anonymous
iframe and the isolated world iframe is now directly
embedded in the page.

As a result, pages are now unable to interfere with any
of the element picker user interface. Pages can now only
see an iframe, but are unable to see the content of that
iframe. The styles applied to the iframe are from a user
stylesheet, so as to ensure pages can't override the
iframe's style properties set by uBO.
2020-09-03 10:27:35 -04:00
Raymond Hill
9eb455ab5e
Isolate element picker dialog from page content world
Related issues:
- https://github.com/gorhill/uBlock/issues/3497
- https://github.com/uBlockOrigin/uBlock-issues/issues/1215

To solve above issues, the element picker's dialog is now
isolated from the page content in which it is embedded.

The highly interactive, mouse-driven part of the element
picker is still visible by the page content.
2020-09-01 12:32:12 -04:00
Raymond Hill
43dba2bd0e
StaticFilteringParser.analyzeExtra() has no argument 2020-09-01 09:57:38 -04:00
Raymond Hill
d2195b4246
Fix rule sorting quirk in "My rules" pane
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1055
2020-08-27 07:04:37 -04:00
Raymond Hill
405c3e1a84
Add visual hint for last selected entry in element picker
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/47
2020-08-26 11:01:37 -04:00
Raymond Hill
817b87e9fc
Fine tune collapsed sections behavior 2020-08-25 14:26:44 -04:00
Raymond Hill
532ed5c390
Add ability to collpase unchanged rules in _My rules_ pane
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/604
2020-08-25 13:23:30 -04:00
Raymond Hill
fdbde27357
Fix default sort quirk
Related feedback:
- dd655473f6 (commitcomment-41730014)
2020-08-24 14:46:25 -04:00
Raymond Hill
0e9d4714e9
Mibor: better variable name 2020-08-24 12:40:36 -04:00
Raymond Hill
dd655473f6
Add ability to sort rules in _My rules_ pane
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1055
2020-08-24 12:39:07 -04:00
Raymond Hill
4150c17f4a
Add concept of "really bad list" to badlists infrastructure
This commit adds concept of "really bad list" to the
badlists infrastructure. Really bad lists won't be
fetched from a remote server, while plain bad list
will be fetched but won't be compiled.

A really bad list is denoted by the `nofetch` token
following the URL.

Really bad lists can cause more serious issues such
as causing undue launch delays because the remote
server where a really bad list is hosted fails to
respond properly and times out.

Such an example of really bad list is hpHosts which
original server no longer exist.
2020-08-22 08:43:16 -04:00
Raymond Hill
23f08f0274
Add support for blocklist of filter lists
Many filter lists are known to cause serious filtering
issues in uBO and are not meant to be used in uBO.

Unfortunately, unwitting users keep importing these
filter lists and as a result this ends up causing
filtering issues for which the resolution is always
to remove the incompatible filter list.

Example of inconpatible filter lists:
- Reek's Anti-Adblock Killer
- AdBlock Warning Removal List
- ABP anti-circumvention filter list

uBO will use the following resource to know
which filter lists are incompatible:
- https://github.com/uBlockOrigin/uAssets/blob/master/filters/badlists.txt

Incompatible filter lists can still be imported into
uBO, useful for asset-viewing purpose, but their content
will be discarded at compile time.
2020-08-21 11:57:20 -04:00
Raymond Hill
f6d1c6402f
Add support for removal of cloud storage entries 2020-08-21 09:18:33 -04:00
Raymond Hill
db79672355
Fix layout issue with cloud storage widget
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1217
2020-08-21 08:57:47 -04:00
Raymond Hill
394a61570c
Use modern popup panel in logger
The logger was still embedding the now deprecated popup
panel.
2020-08-21 08:23:36 -04:00
Raymond Hill
d8b6b31eca
Add support for cloud storage compression
Cloud storage is a limited resource, and thus it
makes sense to support data compression before
sending the data to cloud storage.

A new hidden setting allows to toggle on
cloud storage compression:

name: cloudStorageCompression
default: false

By default, this hidden setting is `false`, and a
user must set it to `true` to enable compression
of cloud storage items.

This hidden setting will eventually be toggled
to `true` by default, when there is good confidence
a majority of users are using a version of uBO
which can properly handle compressed cloud storage
items.

A cursory assessment shows that compressed items
are roughly 40-50% smaller in size.
2020-08-16 11:59:27 -04:00
Raymond Hill
2afcc13ca6
Add widget to convey the amount of sync storage in use 2020-08-14 15:29:25 -04:00
Raymond Hill
24ef0cb753
Fix typo in comment 2020-08-13 09:40:43 -04:00
Raymond Hill
00b790ce72
Add support for more !#if pre-parser directive tokens
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1205
2020-08-13 09:32:34 -04:00
Raymond Hill
45f26d7319
Better parsing of hosts file system addresses
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/877
2020-08-10 10:56:28 -04:00
Raymond Hill
b01cc6ca4f
Fix cloud storage errors not reported in user interface
Related feedback:
- https://www.reddit.com/r/uBlockOrigin/comments/i6e7lr/
2020-08-10 08:30:52 -04:00
Raymond Hill
79ccd23ccf
Also remove references to remove scriptlets
Related commit:
- 7c22a31294
2020-08-06 11:40:18 -04:00
Raymond Hill
f574a7e74d
Remove more cases of svg/use
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1196
2020-08-06 09:05:10 -04:00
Raymond Hill
290f3d124f
Fix stray <symbol> in path attribute
Related commit:
- 12be265e7d
2020-08-05 12:10:03 -04:00
Raymond Hill
12be265e7d
Fix performance issue with SVG-based icons in dashboard
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1196

For yet unknown reasons, in Chromium 84 the rendering of
`svg/use`-based icons in the dashboard causes page load
stall and undue high memory usage when the dashboard is
opened, especially the Filter list pane.

The fix in this commit is to avoid using `svg/use` and to
directly create and insert the `path` element defining an
icon.
2020-08-05 11:36:54 -04:00
Raymond Hill
dae25b0bae
Fix regression breaking filters with --prefixed pseudo-elements
Related feedback:
- https://github.com/uBlockOrigin/uBlock-issues/issues/89#issuecomment-668701495
2020-08-04 16:00:22 -04:00
Raymond Hill
4c6ee1e0d3
Fix broken :spath operators starting with >
Related feedback:
- 7dd48a6c8c (r41180568)

Regression from:
- 7dd48a6c8c
2020-08-04 11:30:04 -04:00
Raymond Hill
e44af458c0
Fine tune visuals of CodeMirror's search feature
Added a dotted box around found text occurrences,
as just pale yellow to highlight the text is not
enough to visually distinguish from surrounding text.

Iterating through found text occurrences will now
ensure they are vertically positioned in the middle
of the editor.
2020-08-04 10:14:38 -04:00
C0rn3j
3fed25a52d
Use ISO8061 dates in filter comments 2020-08-03 10:30:36 -04:00
Raymond Hill
50bf999a12
Fine tune CodeMirror editor's search widget
Code review following latest changes.

Also, move the input field to the left so that it
renders properly on smaller displays and does not
jump around when the result position/count numbers
change.

This also makes it easier to add more functionality
to the editor's toolbar in the future.
2020-08-03 08:55:02 -04:00
Raymond Hill
d654a5d6cf
Fix search operation broken by search worker going away
Related commit:
- 23332400f5

Since the search worker can go away after its time-to-live
elapsed, we may need to pass again the haystack on which
search operations are performed.
2020-08-02 12:46:52 -04:00
Raymond Hill
23332400f5
Improve annotations for search operations in CodeMirror editor
Before this commit, CodeMirror's add-on for search occurrences
was limited to find at most 1000 first occurrences, because of
performance considerations.

This commit removes this low limit by having the search
occurrences done in a dedicated worker. The limit is now
time-based, and highly unlikely to ever be hit under normal
condition.

With this change, all search occurrences are gathered,
and as a result:

- All occurrences are reported in the scrollbar instead of
just the 1,000 first

- The total count of all occurrences is now reported, instead
of capping at "1000+".

- The current occurrence rank at the cursor or selection
position is now reported -- this was not possible to report
this before.

The number of occurrences is line-based, it's not useful to
report finer-grained occurences in uBO.
2020-08-02 12:18:01 -04:00
Raymond Hill
90c7e79f4f
Consolidate filter list reverse lookup code into a single file
Since it's possible to execute specific code paths according
to whether the context is that of a worker or not, it's possible
to keep the main/thread code in a single file. Keeping the
main/worker code paths into a single file is more convenient
for both code maintenance and code review.
2020-08-01 10:32:40 -04:00
Raymond Hill
7dd48a6c8c
Allow :upward() operator to select html element
Related feedback:
- https://www.reddit.com/r/uBlockOrigin/comments/hvwwj0/element_hiding_by_url_not_by_domain_is_it_possible/fyzykw0/
2020-07-30 11:58:49 -04:00
Raymond Hill
aa37166ae7
Code review re. content scripts in about:blank frames
Related commit:
- 3b72c7cb04
2020-07-29 07:38:49 -04:00
Raymond Hill
3632c1821e
Tabs opened from about:newtab are not popup candidates
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1184
2020-07-29 07:13:08 -04:00
Raymond Hill
9447829eb1
Fix regression causing logger to fail to report cosmetic filters
Related commit:
- 5c68867b92
2020-07-27 13:30:57 -04:00
Raymond Hill
3df978ffd5
Make usage of space more strict in network filter patterns
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1118

Usage of space in network filter patterns will now be
strictly interpreted as the filter being a hosts file
entry.

Usage of space in any other scenario will cause the
pattern of the network filter to be rejected as
erroneous.
2020-07-27 10:20:11 -04:00
Raymond Hill
e98ea7ea9b
Instantiate procedural filterer instance on demand only
The procedural filterer will be instantiated only when
needed, i.e. only when there are actual procedural
filters to enforce.
2020-07-24 19:08:48 -04:00
Raymond Hill
3b72c7cb04
Ensure about: frames use proper origin
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/688

`about:` frames need to lookup and use the inherited
origin from their parent browsing context for proper
lookup of cosmetic filters.
2020-07-24 18:50:12 -04:00
Raymond Hill
5c68867b92
Deprecate pseudo user styles code
The pseudo user styles code served only browsers based
on Chromium 65 and earlier -- Chromium 66 supports
native user styles and was first released more than two
years ago.

In Chromium-based browsers, the pseudo user styles code
is being unconditionally injected in every page/frame
just in case the browser is version 65 or earlier.

Removing pseudo user styles reduce uBO's main content
script in Chromium-based browsers by more than 20K.

Related thread:
- https://github.com/NanoAdblocker/NanoCore/issues/348#issuecomment-653646507
2020-07-22 10:21:16 -04:00
Raymond Hill
3839d05a99
Auto-update most obsolete asset first
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1165
2020-07-21 07:50:36 -04:00
Raymond Hill
c805950ecf
Fix the logging of cosmetic filters in about:blank frames
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1164
2020-07-20 08:27:00 -04:00
Raymond Hill
85aef306d1
vAPI.tabs.executeScript() can't throw
Related commit:
- aed850978e

No need to mind rejected promise after all,
vAPI.tabs.executeScript() is designed to
not fail -- I had forgotten about this.
2020-07-19 18:38:35 -04:00
Raymond Hill
aed850978e
Mind discarded status of tabs when internally handling them
Related discussion:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1652925#c19

Content scripts should not be injected in discarded tabs, and
a discarded tab should treated as if it does not exist.
2020-07-19 17:41:13 -04:00
Raymond Hill
221983646e
Injects user styles and content scripts in about:blank frames
Related issues:
- https://github.com/uBlockOrigin/uBlock-issues/issues/688
- https://github.com/uBlockOrigin/uBlock-issues/issues/1164

`match_about_blank` is now used for content scripts and
user styles.
2020-07-19 09:06:19 -04:00
Raymond Hill
fb0a442a9a
Fix improperly initialized counter
Related discussion:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1167

Related commit:
- feabfe3793
2020-07-19 09:01:45 -04:00
Raymond Hill
0549bfaf00
Do not implicitly strict-block when pattern contains no token char
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1147
2020-07-18 09:40:38 -04:00
Raymond Hill
feabfe3793
Do let grow subframe dictionary grow unbound
Related discussion:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1652925

It's not clear the code here will fix the reported
issue, but I did identify that the subframe
dictionary of a very long-lived web page can
theoretically grow unbound.
2020-07-18 07:44:26 -04:00
Raymond Hill
3789259fc9
Consider an empty pattern with anchors to be dubious
Related issue:
- https://github.com/ryanbr/fanboy-adblock/issues/1384
2020-07-17 10:08:08 -04:00
Raymond Hill
d5dcf4e9b6
Fix improper handling of srcset in element picker
Regression from:
- 16727d68c8

The issue was causing the element picker to being
unable to select elements with no valid `srcset`
property.

Test case -- trying to select one of the embedded
frames in the following page would fail:
- http://raymondhill.net/ublock/tiles1.html
2020-07-13 11:46:38 -04:00
Raymond Hill
d49a9dce66
Fix spurious rejection of some AdGuard redirect filters
Lines in AdGuard filter lists have trailing `\r`
characters, and these caused the redirect engine
compile code to reject as invalid the redirect
token.

This is trivially fixed by trimming the raw option
strings before parsing it in the redirect engine.
2020-07-13 09:33:38 -04:00
Raymond Hill
ba0d4f8a38
Fix the reporting of invalid static extended filters in the logger
This is a regression caused by the re-factoring necessary
to support the new static filtering parser code.
2020-07-12 13:00:18 -04:00
Raymond Hill
2eec28520f
Fix improper rejecting fitlers with $all,~document options
Related feedback:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1134#issuecomment-657122472
2020-07-12 10:39:57 -04:00
Raymond Hill
fc84a30cce
Mind \b in regex-based filters when trying to extract token
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1145#issuecomment-657036902
2020-07-11 10:32:04 -04:00
Raymond Hill
e44a568278
Add CoreMirror's code-folding ability to list editor/viewer
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1134

CodeMirror's code folding reference:
- https://codemirror.net/doc/manual.html#addon_foldcode

This commit adds support for code-folding to the filter
list editor/viewer.

The following blocks of code are foldable by clicking the
corresponding marker in the gutter:

- !#if/#endif blocks
- !#include blocks

Addtionally, the following changes:

- The `!#include` line is now preserved when importing a
  sublist
- The `!#if` directives will be syntax-colored according
  to whether they evaluate to true or false on the current
  platform
- Double-clicking on a foldable line in the gutter will
  select the content of the foldable block
- Minor visual improvement to matching brackets
2020-07-10 08:01:39 -04:00
Raymond Hill
ebf7fb145e
Fine tune auto-completion for !#if directives
Auto-completion will work only for uBO's own
tokens, compatibility-related tokens[1] will not be
taken into account for auto-completion.

The reason is to not have the compatibility-related
tokens get in the way of auto-completion in order
to not inconvenience uBO's filter list maintainers.

[1] `adguard_ext_chromium`, `adguard_ext_firefox`,
    etc.
2020-07-09 08:09:51 -04:00
Raymond Hill
83c01fb352
Add syntax highlighting/auto-completion for preparsing directives
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1134

Invalid values for `!#if ...` will be highlighted as errors.

Auto completion is now supported for both the directives
themselves and the valid values for `!#if ...`.

For examples, when pressing ctrl-space:

- `!#e` will auto-complete to `!#endif`
- `!#i` will offer to choose between `!#if ` or `!#include `
- `!#if fir` will auto-complete to `!#if env_firefox`

Additionally, support for some of AdGuard preparsing
directives, i.e. `!#if adguard` is now a valid and will be
honoured -- it always evaluate to `false` in uBO.
2020-07-08 09:52:27 -04:00
Raymond Hill
18a5f41a04
Better processing of Expires directive in filter list
In case of invalid `Expires` value -- i.e. `NaN` -- do
not use `1` as default value, just let uBO pick the
value according to the global default (which is `5` as
of commit time).
2020-07-06 08:31:53 -04:00
Raymond Hill
dc64cfbd97
Fix properly reporting invalid filter options
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1134

Specifically;

- `beacon`, `ping`, and `websocket` cannot be redirected;
- it's ok to not specify a type when redirecting to `empty`
  resource;
- `csp=` option can't be mixed with other types, redirec
  directives, and more `csp=` options.
2020-07-05 14:11:15 -04:00
Raymond Hill
cd1a3d22cd
Or just simplify by combining both conditions... 2020-07-05 09:17:06 -04:00
Raymond Hill
37f5b3d642
Minor code review re. element picker
Avoid potentially adding element twice to the
resultset.
2020-07-05 09:12:45 -04:00
Raymond Hill
16727d68c8
Fix parsing of srcset attribute in element picker
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1071

Additionally, match unconditionally against `srcset` attribute
when trying to find matching elements in the page. For example,
sometimes an img element may set both `src` and `srcset`
properties, they should not be deemed mutually exclusive.
2020-07-05 08:44:14 -04:00
Raymond Hill
0da34f7edf
Handle properly Unicode characters in static network filters
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/772

Unicode characters inside hostname part of a filter will
be converted to punycode.

Unicode characters anywhere else in the pattern will be
percent-encoded.

Unicode characters which cannot be encoded will cause a
filter to be invalid.
2020-07-04 14:47:33 -04:00
Raymond Hill
a85a908f09
Compile scriptlet filters to their canonical, unaliased name
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1031
2020-07-04 11:02:31 -04:00
Raymond Hill
000886002d
Fix regression in reverse lookup of cosmetic filters
Related commit:
- d1715fb19f
2020-07-04 10:11:53 -04:00
Raymond Hill
d1715fb19f
Fix logger's reverse-lookup of selectors with no \w characters
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1139
2020-07-03 14:32:12 -04:00
Raymond Hill
941898e54e
Fix highligthing of FQDN match in logger
Related feedback:
- https://github.com/uBlockOrigin/uAssets/issues/7619#issuecomment-653010310

Also fixed strict-blocking of URL using FQDN.
2020-07-03 14:28:03 -04:00
Raymond Hill
aab3812089
Ignore !#include directives within inactive !#if/!#endif blocks
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1113
2020-07-03 08:43:40 -04:00
Raymond Hill
a6355cecea
Output built-in benchmark results regardless of consoleLogLevel 2020-07-02 12:39:40 -04:00
Raymond Hill
c6397e3d30
Fix handling of non-punycodable Unicode characters
Related feedback:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1118#issuecomment-650730158
2020-06-28 08:28:29 -04:00
Raymond Hill
a08cdd721a
Fix edge case involving filter with a single wildcard
This fix the case of the following filter:

    trk*.vidible.tv

Not matching:

    https://trk.vidible.tv/trk/.vidible.tv

The wildcard is supposed to match any number of
characters, including zero characters. The issue
is that the code was not matching zero characters.

This is due to an incorrect comparison in
BidiTrieContainer.indexOf(), causing the code to
bail out before testing for the zero character
condition.
2020-06-27 07:58:46 -04:00
Raymond Hill
db198b0904
Fix regression in pure hostname filters with wildcard
The regression broke filters of the form:

    ||trk*.vidible.tv^

The new parser will eventually interpret differently
wildcard characters when they are used in a manner
meant to represent only hostname-valid characters,
but this will come in a future version -- for now
the default meaning must be preserved until the
static network filtering engine is modified to
enforce the new interpretation.
2020-06-25 17:13:42 -04:00
Raymond Hill
ec4de80345
Revert "Reject downloaded lists which are deemed truncated"
This reverts commit de219dae26.
2020-06-21 13:31:13 -04:00
Raymond Hill
86d28b57c3
Outright reject patterns with more than one space character
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1118

This is not a complete fix for the reported issue, but this
should catch many reported cases of invalid filters in the
wild.
2020-06-21 08:08:18 -04:00
Raymond Hill
de219dae26
Reject downloaded lists which are deemed truncated
Related feedback:
- https://www.reddit.com/r/uBlockOrigin/comments/hbpo86/

For unknown reasons at this point, it appears some users
end up with a truncated version of EasyList, leading to
improper blocking in uBO.

This commit adds a heuristic to discard a downloaded list
when its new size is more than 25% smaller than the
currently cached version.
2020-06-19 11:35:44 -04:00
Raymond Hill
3f9c5b9bc4
Fix regression in syntax highlighting
Specifically, fix trailing comments improperly
rendered as filter option.

Regression from:
- https://github.com/gorhill/uBlock/commit/6d8b310d9422#diff-fb99537d908d0afc8d76e7c98bbc9fea
2020-06-17 12:32:52 -04:00
Raymond Hill
bbf1cb22a0
Improve auto-completion heuristics
Related commit:
- 3e72a47c1f
2020-06-17 08:12:47 -04:00
Raymond Hill
001e1ea21e
Fix syntax-highlighting of regex-based filters
Regression from:
- https://github.com/gorhill/uBlock/commit/6d8b310d9422#diff-fb99537d908d0afc8d76e7c98bbc9fea
2020-06-16 18:56:26 -04:00
Raymond Hill
aa000e282e
Add auto-completion for procedural operators
Related commit:
- 3e72a47c1f
2020-06-16 08:59:55 -04:00
Raymond Hill
c9cfd62c21
Add auto-completion capability for filter options
Related commit:
- 3e72a47c1f

Use ctrl-space to auto-complete filter options and
`redirect=` resources in _"My filters"_ pane.
2020-06-15 19:05:39 -04:00
Raymond Hill
3e72a47c1f
Add support for auto-completion in _My filters_ pane
This commit adds CodeMirror's auto-completion capability
to the _My filters_ pane.

Currently, auto-completion is available for scriptlet
tokens: pressing ctrl-space while the text cursor is
positioned where a scriptlet token should appear will
cause auto-completion to kick-in. In case of ambiguity,
CodeMirror's widget to pick a specific scriptlet will
appear.
2020-06-15 09:15:13 -04:00
Raymond Hill
f8b0ee0fdc
Fix validation of redirect rules with empty resource
The `empty` resource is a special case, it does not
require a network type to be present to be valid.
2020-06-15 07:40:18 -04:00
Raymond Hill
cb5437b161
Support redirect rules with no pattern
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/977

No pattern will imply `*` for the redirect destination
part of the rule.
2020-06-14 15:09:35 -04:00
Raymond Hill
0e32e4391d
Add ability to comment out block of filters
Pressing Tab in _My filters_ will toggle the
commenting out of filters in the current
selection or current line if no selection.
2020-06-14 14:02:33 -04:00
Raymond Hill
6d8b310d94
Minor code review of static filtering parser
Rename `l` property to `len`, to avoid ambiguity as
`l` could mean _left_ or _length_. Typically `l` is
to be used for _left_ (whereas `r` is to be used for
_right_).

Additionally, add CodeMirror's bracket-matching and
bracket auto-closing to _My filters_ pane and and
bracket-matching to asset viewer page.
2020-06-14 12:05:42 -04:00
Raymond Hill
2523959f20
Better handling of separator errors in domain lists
Specifically, do not invalidate valid hostnames when
there are extraneous separators: that sort of error
will be visually highlighted but will not otherwise
prevent a filter from being properly enforced.
2020-06-13 17:04:42 -04:00
Raymond Hill
a211c2c95d
Convert selector compiler closured code into standalone class
This ensures proper garbage collection once the parser
is no longer referenced -- this is important now that
the parser is instantiated on-demand only.
2020-06-13 12:53:49 -04:00
Raymond Hill
0ec4c911dd
Fix improper handling of regex flags in search widget
Reported internally.

Potential regex flags are passed as is to RegExp contructor,
and in case of failure the query is deemed a plain text one.

Related commit:
- 8de67d22bd (diff-3f4aa453cefa49f6431f1bba3bb53a8e)
2020-06-13 11:13:48 -04:00
Raymond Hill
1a082e0581
Expand parser's ability to process static extended filtering
This commit moves some of the parsing logic of static
extended filtering into the static filtering parser; this
allows better syntax highlighting and creation-time
error-catching for cosmetic, HTML, and scriptlet filters.
2020-06-13 08:48:56 -04:00
Raymond Hill
681bd70116
Fix reverse lookup of generic cosmetic exception filters
Reported internally.
2020-06-11 07:18:45 -04:00
Raymond Hill
6926030b68
Expand static parser to better detect invalid syntax
Specifically:

There can't be more than one `redirect` or `csp`
option.

There can be no type specified when there is a
`csp` option.

There must be one single network-related type when
there is a `redirect` option. Since `empty` and
`mp4` imply a `redirect` and a network-related
type, these can't be used along another `redirect`
or network-related type.

Related commit:
- 01b1ed9a98
2020-06-10 12:15:50 -04:00
Raymond Hill
d784fda98b
Fix matching of filters with trailing ^|
Related feedback:
- https://www.reddit.com/r/uBlockOrigin/comments/h08132/can_we_enable_javascript_on_the_homepage_but/ftkxvc5/

The right bound of the match needs to be incremented
when a trailing `^` matches a character.
2020-06-10 09:53:21 -04:00
Raymond Hill
bc7f149252
Minor code review of static parser code 2020-06-09 11:58:27 -04:00
Raymond Hill
08eca13364
Visually emphasize regex-based pattern
To help prevent mistakenly creating regex-based
patterns.
2020-06-08 12:39:31 -04:00
Raymond Hill
58c6baf0ba
Syntax highlight dubious patterns
Network filters with dubious patterns are discarded
by the static network filtering engine.
2020-06-08 08:53:29 -04:00
Raymond Hill
5752ad58b8
Code review of option iterator code
Related commit:
- 01b1ed9a98

Reuse returned item each time the iterator is
restarted.
2020-06-07 19:30:30 -04:00
Raymond Hill
41523d21db
Prepare static parser to better detect invalid filters
Additionally, syntax-color invalid regular expression.
2020-06-07 11:55:27 -04:00
Raymond Hill
7dc962281f
Set max token length on parser for consistent compilation
Reported internally. The issue could cause the logger
to be unable to successfully reverse-lookup a filter
list for a filter which had tokens longer than 6
characters followed by wildcard.

Regression from:
- 01b1ed9a98
2020-06-07 08:50:20 -04:00
Raymond Hill
f869348d1f
Fix string slice extraction from parser
Reported internally.

Regression from:
- 01b1ed9a98

The regression was made apparent be the fact that
AdGuard filter lists have lines ending with the
CR character.
2020-06-07 07:40:00 -04:00
Raymond Hill
0d1a532bfa
Disregard possible trailing carriage return characters
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1101
2020-06-06 17:42:21 -04:00
Raymond Hill
b34e6da6ec
Split fetching settings/storage used in Settings pane
Computing storage-used figures can take longer than
usual sometimes when a lot of filter lists are enabled,
and this can cause the Settings pane to take longer to
be filled the first time it is opened. Fetching
settings and storage-used figures separately removes
that potential delay (they were fetched together in
a single Promise.all() call).
2020-06-06 08:45:24 -04:00
Raymond Hill
6633e2635d
Fix dealing with trailing newline characters
Regression from:
- 01b1ed9a98

The new parser needs to be able to deal with trailing
newline characters, which if present will be interpreted
as trailing spaces.
2020-06-05 09:57:48 -04:00
Raymond Hill
01b1ed9a98
Add a new static filtering parser
A new standalone static filtering parser is introduced,
vAPI.StaticFilteringParser. It's purpose is to parse
line of text into representation suitable for
compiling filters. It can additionally serves for
syntax highlighting purpose.

As a side effect, this solves:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1038

This is a first draft, there are more work left to do
to further perfect the implementation and extend its
capabilities, especially those useful to assist filter
authors.

For the time being, this commits break line-continuation
syntax highlighting -- which was already flaky prior to
this commit anyway.
2020-06-04 07:18:54 -04:00
Raymond Hill
46197a11c5
Possibly fix popup document not being found
This is a blind fix attempt, related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1085
2020-05-31 07:08:24 -04:00
Raymond Hill
3508d476ff
Fix bad logger output for miss set of hostnames
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1076
2020-05-29 07:19:23 -04:00
Raymond Hill
a974562f7e
Expand HTML entities in title attribute
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1074
2020-05-27 06:54:11 -04:00
Raymond Hill
cd1fef2d5c
On re-consideration, remove popupPanelGodMode
`filterAuthorMode` is sufficient to enable the
ability to create _allow_ rules from popup panel.
2020-05-25 07:08:02 -04:00
Raymond Hill
8310e91e0e
Fix mixing hostname and entity in domain= option
Reported internally.

Related commit:
- 3c67d2b89f
2020-05-25 07:02:49 -04:00
Raymond Hill
3c67d2b89f
Add support for entity-matching in domain= filter option
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1008

This commit adds support entity-matching in the filter
option `domain=`. Example:

    pattern$domain=google.*

The `*` above is meant to match any suffix from the Public
Suffix List. The semantic is exactly the same as the
already existing entity-matching support in static
extended filtering:

- https://github.com/gorhill/uBlock/wiki/Static-filter-syntax#entity

Additionally, in this commit:

Fix cases where "just-origin" filters of the form `|http*://`
were erroneously normalized to `|http://`. The proper
normalization of `|http*://` is `*`.

Add support to store hostname strings into the character
buffer of a hntrie container. As of commit time, there are
5,544 instances of FilterOriginHit, and 732 instances of
FilterOriginMiss, which filters require storing/matching a
single hostname string. Those strings are now stored in the
character buffer of the already existing origin-related
 hntrie container. (The same approach is used for plain
patterns which are not part of a bidi-trie.)
2020-05-24 10:46:16 -04:00
Raymond Hill
196746386c
Double-tap ctrl key to toggle god mode in popup panel
After many feedback:
- https://github.com/gorhill/uBlock/commit/aec2f81884c5#commitcomment-39385794

This is convenient enough and this still fulfill
the idea of not being able to create mindlessly
allow_ rules.
2020-05-23 19:48:28 -04:00
Raymond Hill
a018937792
Use ctrl-spacebar instead of spacebar to toggle god mode
Related feedback:
- https://github.com/gorhill/uBlock/commit/aec2f81884c5#commitcomment-39385794
2020-05-23 09:26:21 -04:00
Raymond Hill
aec2f81884
Add ability to toggle god mode in popup panel
Pressing spacebar will toggle god mode in popup
panel.

This capability shouldn't encourage people to
misuse _allow_ rules as having to press the
space bar act as an extra necessary step which
purpose is to make the creation of _allow_ rules
more mindful.
2020-05-23 06:37:04 -04:00
Raymond Hill
162e537270
Make the creation of _allow_ rules in panel an opt-in feature
There have been too many examples out there of users
opting-in to "I am an advanced user" and yet still misusing
dynamic filtering by creating _allow_ rules where _noop_
rules should be used.

Creating _allow_ rules has serious consequences as these
override blocking static filters and can potentially
disable other advanced filtering ability such as
HTML filtering and scriptlet injection -- often used
to deal with anti-blocker mechanisms.

The ability to point-and-click to create _allow_ rules
from the popup panel is no longer allowed by default.

An new advanced setting has been added to enable
the ability to create _allow_ rules from the popup
panel, `popupPanelGodMode`, which default to `false`.
Set to `true` to restore ability to set _allow_ rules
from popup panel.

Since the creation of _allow_ rules is especially useful
to filter list authors, to diagnose and narrow down site
breakage as a result of problematic blocking filter,
the creation of _allow_ rules will still be available
when the advanced setting `filterAuthorMode` is `true`.

This change is probably going to be problematic to all
those users who were misusing dynamic filtering by
creating _allow_ rules instead of _noop_ rules -- but
the breakage is going to bring their misusing to their
attention, a positive outcome.
2020-05-22 11:35:44 -04:00
Raymond Hill
5f4e6d80e0
Add ability to lock firewall height to basic pane height
New advanced setting: `popupPanelHeightMode`.
Default value: 0

Set to 1 to force the height of the firewall pane
to be no more than the height of the basic pane.

Related feedback:
- https://github.com/uBlockOrigin/uBlock-issues/issues/785#issuecomment-622327450
2020-05-22 08:47:51 -04:00
Raymond Hill
a5a447186b
Fix computing the path of nested lists
Regression from:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1034

Nested lists must have their path computed from their
parent list path, not from the path of the root list.
2020-05-20 12:38:41 -04:00
Raymond Hill
9f7e5b621d
Add new advanced setting: uiStyles
Default to `unset`.

To allow users to bypass uBO's default CSS styles in
case they are causing issues to specific users. It is
the responsibility of the user to ensure the value of
`uiStyles` contains valid CSS property declarations.
uBO will assign the value to `document.body.style.cssText`.

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

For example, in the case of the issue above, one could
set `uiStyles` to `font-family: sans-serif` to force uBO
to the system font for its user interface.
2020-05-19 10:33:36 -04:00
Raymond Hill
5229e0c810
Ensure either .desktop or .mobile class is set
One of these must always be present. This commit
fixes a theoretical case where neither of these
classes are set on the body element.
2020-05-19 10:29:09 -04:00
Raymond Hill
2237d97466
Even more fine tuning of UI as per feedback
Fix unstyled checkbox in "Filter lists" pane.
Related feedback:

https://github.com/uBlockOrigin/uBlock-issues/issues/1027#issuecomment-629780098

Hopefully fix glitchy popup panel when opened
from the extension icon. By default the panel is
configured to be rendered in landscape. It will be
toggled programmatically to portrait mode when
either the environment is mobile or the viewport
is horizontally constrained. Related feedback:

https://github.com/uBlockOrigin/uBlock-issues/issues/1027#issuecomment-629712393

New layout for rendering the statistics text
strings in landscape mode, so as to avoid text
wrapping and to allow a slightly narrower basic
pane. Related discussion:

https://github.com/uBlockOrigin/uBlock-issues/issues/1027#issuecomment-629785966
2020-05-17 08:49:37 -04:00
Raymond Hill
5c7aa850dc
More fine tuning of new UI as per feedback
Position the backup/restore/reset buttons at the
bottom in Settings pane. Related feedback:

https://github.com/gorhill/uBlock/commit/5bee33253f45#commitcomment-39221329

Use a fixed with for the fireall pane. Related
feedback:

https://github.com/uBlockOrigin/uBlock-issues/issues/1027#issuecomment-629668065

Fall back to a polyfill compact notation when
rednering large numbers in popup panel when the
required Intl.NumberFormat API is not fully
supported, at the expense of not being i18n-
compliant. Related discussion:

https://github.com/uBlockOrigin/uBlock-issues/issues/1027#issuecomment-629696676
2020-05-16 17:51:01 -04:00
Raymond Hill
8859d4352f
Restore ability to set popup panel font size in advanced settings
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/397

Issue above will require non-trivial changes, so for
now users who prefer smaller/larger popup panel can
fall back on advanced setting `popupFontSize`:

https://github.com/gorhill/uBlock/wiki/Advanced-settings#popupfontsize
2020-05-16 07:36:03 -04:00
Raymond Hill
8ceed3d4ca
Fix !#include directive when loading from packaged lists
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1034
2020-05-15 18:06:14 -04:00
Raymond Hill
4fa5c6b88e
Fix uselessly allocating one extra WASM page
spotted as a result of stepping in the code. The issue
is that a uBP "page size" might differ from a WASM
page size, which is always 65536 bytes.
2020-05-15 12:03:05 -04:00
Raymond Hill
f060bb5382
Replace FilterPlainHostname with composite filter
FilterPlainHostname, an atomic filter unit, has been
removed and is being replaced with a composite filter
made of a pattern filter and a filter which test
hostname boundaries.

Doing so enables filters formerly being represented
by FilterPlainHostname to be now represented as a
plain pattern, and thus to be potentially stored in
a bidi-trie.

Comparing the new filter histogram with the previous
one:

FilterPatternPlain      24612   26432    1820
FilterComposite         17656   17125    -531
FilterPlainTrie Content 12977   13519     542
FilterPlainHostname      2904       0   -2904
FilterBucket             2121    1961    -160
FilterPlainTrie          1418    1578     160

Which means:
- An extra 542 patterns could be stored in bidi-tries
- There are 531 less composite filters needed
- An extra 160 buckets could be aggregated into 160
  bidi-trie

Memory-wise, it's a marginal gain (as per Chromium's
Javascript VM instance figure) -- i.e. not worth
talking about). CPU-wise, no measurable difference.

The benefit is that I consider this conceptually
simplifies slightly the static network filtering
code base.
2020-05-15 11:00:16 -04:00
Raymond Hill
3d3cd58d9f
Properly auto-toggle on firewall pane [regression]
... when enabling advanced user mode. A regression
caused the pane to be toggled to hidden state instead
of being toggled to shown state.
2020-05-12 12:08:32 -04:00
Raymond Hill
19e6936ed9
Do not show per-site switches at first install time
I meant to not show the per-site switches by default
at first install. I caught this misconfiguration after
testing a first-install scenario.
2020-05-12 10:11:24 -04:00
Raymond Hill
f842ab6d3c
Add new scriptlet to allow blocking Amazon's apstag.js
Related issues:
- https://github.com/NanoMeow/QuickReports/issues/3717
- https://www.reddit.com/r/uBlockOrigin/comments/ghjqph/

The specific issue on the mentioned site is that the
site's code expect `window.apstag.fetchBids` to call
client-supplied function. The new scriptlet defuse this
by calling the client code with an empty array.
2020-05-11 07:57:14 -04:00
Raymond Hill
c42f23c131
Rerrange popup panel layout initializing code
Specifically, the sticky controls box is re-parented
pre-emptively instead of waiting for the decision as
to whether the panel must be toggled into a vertical
layout mode.
2020-05-08 09:16:20 -04:00
Raymond Hill
b226873bdb
Wait a bit longer before testing viewport width 2020-05-07 15:42:30 -04:00
Raymond Hill
2d960cf530
Test against window.innerWidth to toggle vertical layout 2020-05-07 15:24:39 -04:00
Raymond Hill
80b758e18d
Let the platform pick the default suspend state at launch
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1004

The fix is trivial enough that I feel confident to make
it part of current RC cycle. There are many reports of
block page at launch on Chromium.

The fix is to let the platform pick it's natural suspend
state rather than force it. Once advanced settings are
read, the suspend state will for toggled only if
`suspendTabsUntilReady` is either `yes` or `no`. This
there should no longer be blocked page on Chromium at
launch when using default settings.

Related feedback:
- https://www.reddit.com/r/uBlockOrigin/comments/gac2h8/
2020-05-06 20:30:58 -04:00
Raymond Hill
563ba9136c
Improve heuristic to toggle panel to vertical layout
By using a larger tolerance.

Also, ensure that the hover visuals are still
being used in vertical layout mode on non-mobile
devices.
2020-05-06 10:39:03 -04:00
Raymond Hill
6c90cdae3a
Avoid fractional pixel in viewport height
Fractional pixel could lead to minor scrollbar
glitch -- reported internally.
2020-05-05 07:08:38 -04:00
Raymond Hill
c7d196d472
Re-design document-blocked page as per feedback
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1005

There is probably more work to do regarding the
shown URL -- it might be better to truncate it
on small screen display since it can be quite
long sometimes.
2020-05-04 12:41:10 -04:00
Raymond Hill
002a825891
Add tolerance to popup panel when checking viewport width
I meant to add this to last commit:
- a54718862c
2020-05-03 09:26:19 -04:00
Raymond Hill
a54718862c
Maybe fix rare spurious viewport width test in popup panel
In rare instances -- though it definitely happens
eventually -- the popup panel viewport width is seen as
insufficiently wide enough and as a result the popup panel
is toggled into vertical-layout mode.

The added code uses animation frames to delay the
code testing the viewport width. Hopefully this will
work.
2020-05-03 09:18:53 -04:00
Raymond Hill
42dedfbd90
Fine tune power button; fix no-popups switch visual regression 2020-05-02 18:27:53 -04:00
Raymond Hill
c56607fe27
Use encodeURIComponent() instead of encodeURI()
Related issue:
- https://github.com/NanoAdblocker/NanoCore/issues/325
2020-05-02 07:20:17 -04:00
Raymond Hill
38cdb42348
Allow hiding blocked count since install in popup panel
Also, more fine tuning of visuals.

Two new advanced settings, to be left undocumented as
"purposefully undocumented setting".
2020-05-01 19:47:01 -04:00
Raymond Hill
206d217e14
Fix persist/revert tools not being shown after changes
Related feedback:
- https://github.com/uBlockOrigin/uBlock-issues/issues/733#issuecomment-621933750
2020-05-01 07:51:45 -04:00
Raymond Hill
eeae4b2cab
Add ability to open the dashboard with a keyboard shortcut
Related feedback:
- https://github.com/gorhill/uBlock/commit/9a6feb34d546#commitcomment-38852663
2020-04-30 10:31:23 -04:00
Raymond Hill
b295d4a0d0
Make the new "fenix" popup panel the default one
The old "classic" popup panel will still be used
when at least one of the following is true:

- advanced setting `uiFlavor` is set to `classic`; or
- the browser is Chromium 65 or older; or
- the browser is Firefox 67 or older

The default configuration of the new popup panel
at installation time is to show the power button,
statistics and the basic tool icons, i.e. access
to dashboard, logger, pickers.

For existing installations, the new popup panel
will be configured by respecting the existing
configuration of the classic one.

The new popup panel is currently already in use
on Firefox for Android, and the visual redesign
was made according to suggestions and feedback
from <https://github.com/brampitoyo> to be
optimal for Firefox for Android.

The new popup panel will allow closing the following
pending issues:

- https://github.com/uBlockOrigin/uBlock-issues/issues/255
- https://github.com/uBlockOrigin/uBlock-issues/issues/178
2020-04-30 06:54:51 -04:00
Raymond Hill
23633b388d
Fix reported "Storage used:" when info is not available 2020-04-29 10:00:58 -04:00
Raymond Hill
d364eb9668
Minor code review 2020-04-28 18:39:31 -04:00
Raymond Hill
d462b50cec
Improve presentation of advanced settings page
Specifically:

- Fix exception being thrown when createing an
  empty line

- Syntax-color invalid setting names

- Syntax-color non-default values
2020-04-28 11:07:00 -04:00
Raymond Hill
9a6feb34d5
Re-order sections in the new popup panel
The blocking-stuff button icons have been brought
closer to the power button.

The go-somewhere button icons have been moved at
the bottom.

The hostname of the current site is now shown below
the power button. The base domain is bolded.

This re-ordering is for a few reasons:

- The blocking-stuff button icons are now closer
  to the revert/persist/reload transient buttons
  which show up when modifying the blocking
  behavior of uBO.

- The makes it easier to potentially bring in a
  very basic view where only the power button and
  the statistics are shown and all the button
  icons are hidden from view.
2020-04-27 19:01:16 -04:00
Raymond Hill
6259f88598
Add an alias for window.open-defuser scriptlet
As per request from filter list maintainers.

The alias is `nowoif`, in line with other such
defusing scriplets.
2020-04-27 11:24:41 -04:00
Raymond Hill
db9c321855
More work toward re-hauling the user interface
This commit specifically address bringing the
desktop version of the new popup panel's look
and feel more inline with the classic one:

- Hide tool captions on desktop

- Bring back no-popups switch on desktop

- Bring back tooltips on desktop (though they
  are now rendered natively by the browser)

- Use the Photon icons suggested by @brampitoyo
  for the no-popups and no-remote-fonts
  switches
2020-04-27 10:33:49 -04:00
Raymond Hill
8ed60af0f9
Fine tune material design-based checkbox code
Summary:
- Make checkbox nodes self-contained
  (a > b) instead of (a + b)
- Revisit logger to use new checkboxes
2020-04-26 08:44:00 -04:00
Raymond Hill
f9b385ffb1
Standardize checkbox visual to material design
Motivation:
- To align with Firefox Preview's own design
- To uniformize checkbox look and behavior
  across all platforms
2020-04-25 15:19:07 -04:00
Raymond Hill
fe94aa331a
Replace CodeMirror resize code with CSS flex 2020-04-25 10:19:08 -04:00
Raymond Hill
9845e4d61a
Replace old resizing code with CSS flex 2020-04-24 20:10:35 -04:00
Raymond Hill
d2897db2b6
More fine tuning of user interface
Noteworthy:
- Make new popup panel better resize in desktop
  environment
- Fix button visuals in "My rules" pane
- Keep "Update now" button visible until update
  is completed
- Renaming CSS variables for consistency
2020-04-24 09:33:44 -04:00
Raymond Hill
98f19facec
More fine tuning as per feedback
Better constrast for warning color. Related feedback:
- 5bee33253f (commitcomment-38700085)

Revisit how large numbers are rendered in a
compact form in the new popup panel. Feedback
from https://crowdin.com/project/ublock pointed
out that the string to translate was flawed for
Chinese locale (and possibly in some other
locales as well).
2020-04-23 14:19:41 -04:00
Raymond Hill
fea02031c1
Mind possibly too long abbreviation 2020-04-23 10:08:06 -04:00
Raymond Hill
0afe7c2231
More fine tuning of user interface
The rendering of the total number of blocked
requests will now be abbreviated using `M` and
`G` when the block count is respectively above
1 million and 1 billion.

The storage used figure in the Settings pane
will be rendered using KB, MB or GB.
2020-04-23 08:45:43 -04:00
Raymond Hill
04c07f3e10
Use large units for large values in Settings pane
Shorten "Storage used" values using large
units, i.e. shorten rendered values using
KB, MB, and GB for large figures.
2020-04-22 16:30:23 -04:00
Raymond Hill
b277b084d5
More fine tuning of latest UI changes 2020-04-22 11:17:58 -04:00
Raymond Hill
4eef5432a9
More fine tuning of UI 2020-04-22 09:56:37 -04:00
Raymond Hill
5bee33253f
More work toward redesigning the UI
As per email feedback from Mozilla's
https://github.com/brampitoyo

This is yet another incremental step toward
redesigning the UI, much more is left to do.
The idea is to align uBO's UI to that of
Firefox Preview.

Additionally, code has been added to reset
the new popup panel to vertical layout should
the viewport be not wide enough to
accomodate the horizontal layout.

Related feedback:
- https://www.reddit.com/r/uBlockOrigin/comments/g4ufvi/
2020-04-21 16:33:08 -04:00
Raymond Hill
21d7c7ee3d
More fine tuning of various visuals
Summarily:
- Bring back horizontal layout for fenix popup panel
  to be used in desktop environment
- Address feedback from
  https://github.com/gorhill/uBlock/commit/54b68ebd9426#commitcomment-38549940
- Allow future dark theme to be enabled programmatically
2020-04-18 09:48:53 -04:00
Raymond Hill
0bcf04d3dd
Centralize access to browser.storage.local('localStorage')
Related commit:
- 2ac288397c

Instead of having the `localStorage` data being accessed
from different locations, all accesses are now funnelled
to the main process.

Doing so simplifies the code in auxiliary processes and
also remove the need for browser.storage.local.onChanged()
listeners.

No longer using an onChanged() listener also happens to
remove spurious warnings from the Firefox console.
2020-04-15 15:55:29 -04:00
Raymond Hill
042935b22a
Ensure element picker's height is not affected by web sites
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/987
2020-04-15 09:46:12 -04:00
Raymond Hill
efa3c140ab
Fix typo in last commit
Related commit:
- 36711a7c07
2020-04-14 11:57:59 -04:00
Raymond Hill
36711a7c07
Fix denyallow thrown away with pure hostname patterns 2020-04-14 09:10:59 -04:00
Raymond Hill
051cb27f9b
Fix syntax highlighting of line continuation
Thix fixes an exception being thrown when the
line being continued is the last one.
2020-04-13 14:26:17 -04:00
Raymond Hill
94935a4b9e
Pure origin filters can't have denyallow option
This fixes filters of the form:

  *$[...],denyallow=[...],domain=[...]
  |http://$[...],denyallow=[...],domain=[...]
  |https://$[...],denyallow=[...],domain=[...]
2020-04-13 14:22:21 -04:00
Raymond Hill
e917213e81
Sixth pass to re-design the dashboard
Related commits:
- 0662767dd6
- 99b2a0a761
- a8e3118fea
- 453f5450b6
- a45a21f337

This commit focuses on implementing the use of
CSS `var(...)` throughout so as to make it easy
to create themes -- a requirement for uBO to
support a dark theme.

There is still work to do regarding converting
uBO's CSS to completely support `var(...)` but
being able to start using theming will help
complete and fine tune CSS `var(...)` support.

Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/401
2020-04-13 09:19:58 -04:00
Raymond Hill
0662767dd6
Fifth pass to re-design the dashboard
Related commits:
- 99b2a0a761
- a8e3118fea
- 453f5450b6
- a45a21f337

Fine tuned previous work.

Started the use of variable-based color values.
2020-04-11 11:32:43 -04:00
Raymond Hill
99b2a0a761
Fourth pass to re-design the dashboard
Related commits:
- a8e3118fea
- 453f5450b6
- a45a21f337

Roughly, the changes in this commit:
- Make it easier to implement a dark theme eventually:
  - Flatten the look of buttons
  - Remove the use of `opacity` style property as a
    color modifier
- Some work toward removing dependency on FontAwesome
  font
2020-04-10 18:17:12 -04:00
Raymond Hill
a7dc0de98f
Update kbd shortcuts only if kbd shortcuts pane is enabled
Related feedback:
- https://github.com/uBlockOrigin/uBlock-issues/issues/386#issuecomment-611806957
2020-04-10 17:25:36 -04:00
Raymond Hill
a8e3118fea
Third pass to re-design the dashboard
Related commits:
- 453f5450b6
- a45a21f337

This commit fixes parts of the re-design not
rendering as intended as per <https://github.com/brampitoyo>'s
feedback screenshots.

The dashboard tab buttons have been converted to
`span` tags (from `a` tags), thus eliminating
the unwanted side effect of the text being
rendered as unvisited links (blueish).

The font size intended for touch screens was not
taking effect due to bad cut & paste.

Other minor adjustments to improve consistency
in spacing.
2020-04-09 09:20:29 -04:00
Raymond Hill
4687c60bf9
Support fetching assets from CDNs when auto-updating
This commit add the ability to fetch from CDN servers
when an asset is fetched as a result of auto-update.

If an asset has a `cdnURLs` entry in `assets.json`,
the asset will be auto-updated using one of those
CDN URLs. When many CDN URLs are specified, those
URLs will be shuffled in order to spread the bandwidth
across all specified CDN servers. If all specified CDN
servers fail to respond, uBO will fall back to usual
`contentURLs` entry.

The `cdnURLs` are used only when an asset is
auto-updated, this ensures a user will get the more
recent available version of an asset when manually
updating.

The motivation of this new feature is to relieve
GitHub from acting as a CDN (which it is not) for
uBO -- an increasing concern with the growing adoption
of uBO along with the growing size of key uBO assets.
2020-04-08 09:57:55 -04:00
Raymond Hill
a45a21f337
Second pass to re-design the dashboard
Related commit:
- 453f5450b6

The changes in this commit are mostly related
to the "Filter lists" pane.

An eye icon has been added, which purpose is
to view the content of a list. Clicking on the
name of the list will toggle the list's
checkbox.
2020-04-06 14:00:19 -04:00
Raymond Hill
453f5450b6
First pass to Re-design the dashboard
This is a first pass in which only the dashboard
navigation widget and the "Settings" pane have
been revisited.

Reference work:
- https://app.abstract.com/share/54f1465e-8d1c-4e7b-9ae4-f37e21bef7fe
2020-04-05 15:19:07 -04:00
Raymond Hill
20332c65b4
No need for "Shortcuts" pane in Firefox 74 and above
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/386
2020-04-05 09:47:22 -04:00
Raymond Hill
df08b12d48
Fix race condition at browser launch re. cosmetic filtering
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/974

Related feedback:
- https://www.reddit.com/r/uBlockOrigin/comments/fuscia/

The race condition was that a content script could
query the main process to retrieve cosmetic filters
while the cosmetic filters had not been yet fully
loaded into memory. The fix ensure that an already
injected content script will re-query once the
cosmetic filters are fully loaded in memory at
browser launch time.
2020-04-04 11:34:43 -04:00
Raymond Hill
1295e25961
Remove unused property 2020-04-03 09:07:22 -04:00
Raymond Hill
044a1dd6ee
Fix :style exception filters not being reported in logger
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/962

Regression from:
- 72bb700568
2020-03-26 09:19:02 -04:00
Raymond Hill
2f927847f2
Discard :style() filters chained to procedural operators
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/961
2020-03-26 08:38:22 -04:00
Raymond Hill
11d24abea0
Move proxy-detection code to Firefox-specific code
Related commit:
- https://github.com/uBlockOrigin/uBlock-issues/issues/911

The motivation is to avoid executing code which is
unnecessary on platforms not supporting the browser.dns
API.
2020-03-23 13:31:43 -04:00
Raymond Hill
0c30bee3e3
Fix typo in proxy-detecting code
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/911

Related commit:
- https://github.com/gorhill/uBlock/commit/3f7ece94691f
2020-03-23 12:23:05 -04:00
Raymond Hill
3f7ece9469
Do not cname-uncloak when a proxy is in use
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/911

Since cname-uncloaking is available only on Firefox
at the moment, the fix is relevant only to Firefox.

By default uBO will no longer cname-uncloak when it
detects that network requests are being being proxied.

This default behavior can be overriden by setting the
new advanced setting `cnameUncloakProxied` to `true`.
The new setting default to `false`, i.e. cname-uncloaking
is disabled when uBO detects that a proxy is in use.

This new advanced setting may disappear once the
following Firefox issue is fixed:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1618271
2020-03-22 14:52:58 -04:00
Raymond Hill
f5204235b7
Use prime number to generate cache-bypass token
Related discussion:
- https://github.com/gorhill/uBlock/commit/048bfd251c9b#r37972005

From <https://github.com/gwarser>:

> I think this should be "modulo prime", not 12.
> If someone always turn on PC in "8am" there is
> a slight chance to hit cache.
2020-03-22 11:31:06 -04:00
Raymond Hill
381498daa2
Reorganize filter instances deduplication code
Related commit:
- https://github.com/gorhill/uBlock/commit/ab629b9e1093
2020-03-19 13:42:06 -04:00
Raymond Hill
a36566b348
Allow empty needle in BidiTrieContainer.lastIndexOf()
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/882

Related commit:
- https://github.com/gorhill/uBlock/commit/7c0294bd5f54

The changes in the commit above have been reverted, and
the new fix is to add the ability to handle an empty
needle in BidiTrieContainer.lastIndexOf() -- in which
case the method will return the end of the currently
matched pattern.
2020-03-19 13:16:41 -04:00
Raymond Hill
ab629b9e10
Add filter instance deduplicater in static net filtering engine
Provide a way to optionally deduplicate filter
instances, useful for filter instances with:

- high likelihood of duplication; and
- non-trivial memory footprint per instance
  - For examples, filter instances to implement
    `domain=`, `denyallow=`, `csp=`.

Cursory tests show this helps further reduce
uBO's memory footprint.
2020-03-18 09:06:33 -04:00
Raymond Hill
c3bc2c741d
Add support for cname type and denyallow option
This concerns the static network filtering engine.

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

* * *

New static network filter type: `cname`

By default, network requests which are result of
resolving a canonical name are subject to filtering.
This filtering can be bypassed by creating exception
filters using the `cname` option. For example:

    @@*$cname

The filter above tells the network filtering engine
to except network requests which fulfill all the
following conditions:

- network request is blocked
- network request is that of an unaliased hostname

Filter list authors are discouraged from using
exception filters of `cname` type, unless there no
other practical solution such that maintenance
burden become the greater issue. Of course, such
exception filters should be as narrow as possible,
i.e. apply to specific domain, etc.

* * *

New static network filter option: `denyallow`

The purpose of `denyallow` is bring
default-deny/allow-exceptionally ability into static
network filtering arsenal. Example of usage:

    *$3p,script, \
        denyallow=x.com|y.com \
        domain=a.com|b.com

The above filter tells the network filtering engine that
when the context is `a.com` or `b.com`, block all
3rd-party scripts except those from `x.com` and `y.com`.

Essentially, the new `denyallow` option makes it easier
to implement default-deny/allow-exceptionally in static
filter lists, whereas before this had to be done with
unwieldy regular expressions[1], or through the mix of
broadly blocking filters along with exception filters[2].

[1] https://hg.adblockplus.org/ruadlist/rev/f362910bc9a0

[2] Typically filters which pattern are of the
    form `|http*://`
2020-03-15 12:23:25 -04:00
Raymond Hill
bc700e691c
Fix srcset handling in element picker
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/923

Use current page's hostname instead of that of
image URLs to decide whether to reset pattern
union with previous picker sessions.

The fixed issue arose from the fact that the
page uses URLs from different origins in a
single srcset attribute.
2020-03-15 08:45:17 -04:00
Raymond Hill
ca80d2826b
Add indentation requirement for line continuation
Related commit:
- https://github.com/gorhill/uBlock/commit/703c525b01aa

This adds an indentation requirement for line
continuation to take place. The conditions are now
as follow:
- Current line ends with ` \`: ASCII space + backslash
- Next line starts with `    `: four ASCII spaces
2020-03-15 08:15:17 -04:00
Raymond Hill
703c525b01
Support line continuation in filter lists
If a line in a filter list ends with a space
(ASCII code 32) followed by a backslash
(ASCII code 92), those two characters will be
removed, the line will be trimmed and the next
line will be trimmed and concatenated to form
a new, longer line.

The purpose is to give filter list authors
a way to visually break apart unduly long
filters and thus make maintenance easier.

When line continuation is used, it is suggested
that the extra lines are prepended with four
space so as to make it more visually obvious that
the extra line(s) are the continuation of a
previous line.

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

The filter referenced in the above issue was the
motivation to implement this feature:
- https://hg.adblockplus.org/ruadlist/rev/f362910bc9a0

I verified and could not find any instance in major
filter lists of lines ending with ` \`, thus the
change should be safe.
2020-03-14 13:34:13 -04:00
Raymond Hill
2cbbc30084
Also remove text node in :remove() operator
Related discussion:
- https://github.com/gorhill/uBO-Extra/issues/119#issuecomment-537842967

As an incidental side effect, this may or may not
prevent execution of the content of some inline
script tags.
2020-03-09 11:34:49 -04:00
Raymond Hill
1d9421b8b2
Improve validation of CSS selector-based cosmetic filters
Reported internally. The following invalid filter was not
discarded by uBO:

    123tvnow.com##.123tv-ads

The correct form should be:

    123tvnow.com##.\31 23tv-ads

Not discarding invalid CSS selector-based cosmetic
filter may break CSS selector-based cosmetic
filtering.
2020-03-08 10:55:19 -04:00
Raymond Hill
72bb700568
Add procedural cosmetic operators remove() and upward()
***

New procedural cosmetic operator: `:remove()`

Related issue:
- https://github.com/gorhill/uBlock/issues/2252

The purpose is to outright remove elements from the
DOM tree. Since `:remove()` is an "action" operator,
it must only be used as a trailing operator (just
like the `:style()` operator).

AdGuard's cosmetic filter syntax `{ remove: true; }`
will be converted to uBO's `:remove()` operator
internally.

***

New procedural cosmetic operator: `:upward(...)`

The purpose is to lookup an ancestor element.

When used with an integer argument, it is synonym of
`:nth-ancestor()`, which will be deprecated and which
will no longer be supported once no longer used in
mainstream filter lists.

Filter lists maintainers must only use `:upward(int)`
instead of `:nth-ancestor(int)` once the new operator
become available in all stable releases of uBO.

`:upward()` can also accept a CSS selector as argument,
in which case the nearest ancestor which matches the
CSS selector will be selected.
2020-03-07 14:25:06 -05:00
Raymond Hill
bef9eedf73
Support hidden hyphen HTML entity in translation work
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/907#issuecomment-590804054
2020-03-02 12:34:50 -05:00
Rory O’Kane
be111c4036
In Element Zapper, support Mac keyboards’ Delete key (#3770)
Override the Backspace key, not just the Delete key, as Mac keyboards have Backspace as the only delete key and label it Delete.

Source of key value: https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values#Editing_keys

More background on Mac keyboard shortcuts: Mac keyboards can emulate Delete using fn+Delete, meaning Forward Delete, but Mac software does not use it except in text editing. When deletion is dangerous, Mac software requires holding a modifier key in conjuction with Delete, but I think it’s better to make deletion easy in this case.

This new binding has a potential downside: if the user Backspace key normally goes Back in history (which can differ across OSs and browsers), this will change the behavior to delete the selected element instead. If the user really wants to go back in history, they will have to press Escape to leave the mode and then press Backspace, or they will have to press an alternative keyboard shortcuts such as Alt+Left. I think the user will rarely want to go back in history in the middle of picking an element, though.

That downside could be mitigated by conditioning the key check on `runtime.PlatformOs` (https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/runtime/PlatformOs). But that would complicate the code a lot compared to the importance of this feature, and such detection would still fail to capture the user’s intent accurately in all cases. I think it’s better to unconditionally accept both Backspace (Delete) and Delete (Forward Delete).
2020-02-28 14:28:00 -05:00
Raymond Hill
da71c3a499
Force console output when explicitly requested from dev tools
Related feedback:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1617666#c0

Not being able to see benchmark results when explicitly
requesting benchmark results is not very user-friendly;
this commit fixes this.
2020-02-25 11:00:58 -05:00
Raymond Hill
c17a9c8a93
Fix spurious warning when force-reloading the dashboard
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/905

Additionally, minor changes to avoid spurious errors in
browser console.
2020-02-24 09:59:35 -05:00
Raymond Hill
7634604aa8
Make element picker mind that network filters are case-insensitive
Related discussion:
- https://github.com/easylist/easylist/pull/4950#issuecomment-590064744
2020-02-24 09:24:54 -05:00
Raymond Hill
3621792f16
Rework/remove remnant of code dependent on localStorage
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/899
2020-02-23 12:18:45 -05:00
Raymond Hill
d16ac963ef
Use correct element id fenix popup panel 2020-02-23 12:16:50 -05:00
Raymond Hill
15470bcbdc
Ensure disableWebAssembly setting is loaded before use
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/899

WASM modules are now loaded on demand rather than at
script evaluation time.
2020-02-22 13:36:22 -05:00
Raymond Hill
2ac288397c
Remove usage of synchronous localStorage API
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/899

browser.storage.local is now used to store non-critical
local settings.

These settings are all collated under the key
`localStorage`, and vAPI.localStorage is an API to
handle access to these values stored under this key.

vAPI.localStorage.getItem() is still synchronous but
its purpose is to return internally cached values --
this minimizes code changes throughout uBO.
2020-02-21 15:34:54 -05:00
Raymond Hill
5da3aaaabf
Properly test for WebAssembly presence before use
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/900
2020-02-21 15:21:25 -05:00
Raymond Hill
ddc2b11657
Fail graciously if no benchmark dataset found 2020-02-21 08:13:15 -05:00
Raymond Hill
b784b7d569
Support loading of benchmark dataset in published versions
New advanced setting: `benchmarkDatasetURL`
Default value: `unset`

To specify a URL from where the benchmark dataset will be
fetched. This allows to launch benchmark operations from
within published versions of uBO, rather than from just
a locally built version.
2020-02-21 08:06:52 -05:00
Raymond Hill
5ccf435754
Add edge-scheme to default whitelist directives
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/879
2020-02-20 16:43:56 -05:00
Raymond Hill
da0ef9454a
Neutralize localStorage access on mobile platform
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/899

window.localStorage is synchronous and thus should be
avoided at launch time. Currently the avoidance is only
for mobile platforms.
2020-02-20 16:40:29 -05:00
Raymond Hill
69a7c6771b
Fine tune fenix UI as per Bram's feedback 2020-02-18 09:53:20 -05:00
Raymond Hill
3fab7bfdb4
Add support for "specific-generic" cosmetic filters
A specific cosmetic filter of the following form...

    *##.selector

... will be unconditionally injected into all web pages,
whereas a cosmetic filter of the form...

    ##.selector

... would be injected only when uBO's DOM surveyor finds
at least one matching element in a web page.

The new specific-generic form will also be disabled when a
web page is subject to a `generichide` exception filter,
since the filter is essentially a generic one -- the only
difference from the usual generic form is that the filter
is injected unconditionally instead of through the DOM
surveyor.

Specific-generic cosmetic filters will NOT be discarded
when checking the "Ignore generic cosmetic filters"
option in the "Filter lists" pane -- since the purpose
of this option is primarily to disable the DOM surveyor.

Specific-generic cosmetic filters should be used
parcimoniously and only when using a normal specific
filter is really impractical.

Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/803
2020-02-14 11:51:05 -05:00
Raymond Hill
8adad98a0d
New way to convey IDN and CNAME info in popup panel
Hostnames which have unpunycoded IDN or canonical
name information will have this information reported
as an extra line under the hostname name in the popup
panel, rather than as a tooltip.

For the fenix UI flavor, the save/revert tools are
now shown regardless of whether the overview area is
visible or not.
2020-02-10 08:06:36 -05:00
JustOff
a806dd4bd2
Add env_legacy to the pre-processor supported tokens (#3768)
This will allow specifically target uBlock Origin for Firefox legacy-based browsers in shared filter lists,
see https://github.com/gorhill/uBlock-for-firefox-legacy/pull/1.
2020-02-09 08:23:00 -05:00
Raymond Hill
760d206bd4
Select default UI according to target platform
More specifically, this commit makes it so that
the new default UI for Firefox Preview will be
automatically selected.

A default platform-specific UI can be cancelled
by setting the advanced setting `uiFlavor` to `-`.
2020-02-06 11:42:12 -05:00
Raymond Hill
4509483c7e
Set tooltip to cname alias in popup panel
The toolip of a canonical name entry (blue)
in the popup panel will provide the alias
hostname related to the canonical hostname
in order to help with rule-making decisions.
2020-02-06 10:18:15 -05:00
Raymond Hill
651955b97c
Throw if mismatched size when unserializing an array buffer
An exception will be thrown if the length of an unserialized
array buffer does not match exactly the original size at
serialization time.
2020-02-04 09:55:02 -05:00
Raymond Hill
609e9a6428
Remove elision of leading wildcard in some filter patterns
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/882

Related commits:
- https://github.com/gorhill/uBlock/commit/a95ef16e064a
- https://github.com/gorhill/uBlock/commit/7971b223855d

Leading wildcards before valid token characters need to
be kept in order to respect the semantic of the filter.
A leading wildcard in such case changes the semantic of
a filter, i.e. two following filters are semantically
different:

    example/abc
    *example/abc

As a result, µBlock.BidiTrieContainer.indexOf() is now
able to deal with a needle of length zero -- which is
what happens in FilterPatternLeft(Ex) with filter
patterns starting with `*` (or `^*`) and followed by
valid token characters (0-9, a-z and %).
2020-02-03 14:09:37 -05:00
Raymond Hill
a95ef16e06
Fix token position value when removing leading wildcard
Related issue:
- https://www.reddit.com/r/uBlockOrigin/comments/ex8ggg/

Regression from:
- https://github.com/gorhill/uBlock/commit/7971b223855d
2020-02-02 10:05:15 -05:00
Raymond Hill
1d51927d2e
Fix handling of end-anchor in redirect patterns
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/872

An end-anchor was treated as literal `|` in the redirect
pattern to match instead of as a end-of-string condition.
2020-02-01 12:47:17 -05:00
Raymond Hill
0627fcfb62
Fix broken row rendering for non-network-based URL
Reported internally by volunteers.

Regression from:
- https://github.com/gorhill/uBlock/commit/3a564c199260#diff-fd76b4e8f9d7bfb2e5e01510c9457633L367
2020-01-31 13:48:17 -05:00
Raymond Hill
fcc7781aef
Use proper popup URL 2020-01-30 12:43:41 -05:00
Raymond Hill
2b0316440e
First draft of popup panel for Firefox Preview
First draft of changes as discussed with Firefox
Preview people.

In order to allow testing/evaluating these changes,
the new advanced setting `uiFlavor` has been added.
Default to `unset`; and can currently only be set
to `fenix`.

The new setting takes effect at launch only. This
new setting is not to be mentioned in official
documentation for now.

This is ongoing work, not open to external feedback.
2020-01-25 09:24:59 -05:00
Raymond Hill
2e0a8951b8
Minor code review 2020-01-23 12:06:40 -05:00
Raymond Hill
043ae117c8
Decouple error handling of lists loading from selfie loading
This commit make it so that if an *unexpected* error is
thrown when trying to load the selfie at launch, the filter
lists will still be loaded as a result.
2020-01-21 10:52:13 -05:00
Raymond Hill
f8ec54c635
Fix compatibility issue with hosts files
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/847

IP address `0` is a valid synonym of `0.0.0.0`.
2020-01-10 11:07:31 -05:00
Raymond Hill
8704e4e620
Improve token extraction from regex-based filters
Tokens which are as long or longer than the max token
length possible do not need to have the prefix part
evaluated against special regex characters. This will
help increase the likelihood of extracting a valid
token from regex-based filters.

Actual case found in EasyPrivacy:

  /^https?:\/\/eulerian..*\/[a-z0-9]{2,12}\.js/$script

Before this commit, uBO was not able to extract a
valid token, while now uBO is able to extract `eulerian`
as a valid token (consequently the regex-based filter
will now be evaluated only when the token `euleria` is
found in a URL).
2020-01-09 10:09:51 -05:00
Raymond Hill
2cf79ef922
Minor code review 2020-01-04 09:32:28 -05:00
Raymond Hill
d0738c0835
Visually distinguish canonical names in popup panel
Further fine-tuning support for canonical names.

Aliased canonical names will be rendered blue
in the dynamic filtering pane of the popup panel.
2019-12-31 16:36:51 -05:00
Raymond Hill
e9abce61a0
Fix unescaped attr value in generated CSS selector
Related feedback:
- https://github.com/NanoAdblocker/NanoCore2/commit/5e625da8fe45#commitcomment-36625096
2019-12-31 16:14:50 -05:00
Raymond Hill
56cc2b1256
Support expanding/collpasing of specific domains
This is related to the list of domains/subdomains in
the dynamic filtering pane of the popup panel.

Related issue:
- https://github.com/gorhill/uBlock/issues/284

Clicking on the empty space of a row will toggle
the visibility of the subdomains.

Additionally, the root context will always be visible
regardless of the expand/collspase state, along with
a visual indicator that a specific domain or subdomain
is the actual root context.  (the root context is the
hostname in which local rules are created).
2019-12-30 09:54:11 -05:00
Raymond Hill
2da8948928
Add basic syntax coloring to advanced settings pane 2019-12-24 10:04:18 -05:00
Raymond Hill
1bb524d12b
Still try to load filter lists after fatal error at launch
Related discussion:
- https://github.com/uBlockOrigin/uBlock-issues/issues/817#issuecomment-565730122

In case of a fatal error at launch, the loading of filter lists
could be skipped. With this commit uBO will still try to load
the filter lists, at least the default ones if no valid selfie
is present.
2019-12-14 11:14:00 -05:00
Raymond Hill
d90c8486aa
Fix reporting of csp-blocked resources in logger
Related feedback:
- https://github.com/uBlockOrigin/uBlock-issues/issues/552#issuecomment-561888900

Regression from:
- https://github.com/gorhill/uBlock/commit/7971b223855d
2019-12-04 19:23:57 -05:00