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

2318 Commits

Author SHA1 Message Date
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
Raymond Hill
34504a0a1a
Fix regex-like filter representation in logger
Related discussion:
- https://github.com/uBlockOrigin/uBlock-issues/issues/805#issuecomment-561500819

uBO was testing for regex-like plain patterns after
prepending `@@` in the case of exception filters, thus
preventing proper detection of regex-like plain
patterns. The filtering engine was not affected, only
the proper rendering of the filter in the logger was
affected.
2019-12-04 10:42:03 -05:00
Raymond Hill
082201d24a
Fix reverse lookup of entity-based cosmetic filters
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/805
2019-12-04 10:10:07 -05:00
Raymond Hill
91e702cebb
Enable CNAME uncloaking by default
Advanced setting `cnameAliasList` has been removed.

New advanced settings:

cnameUncloak:
  Boolean
Default value:
  true
Description:
  Whether to CNAME-uncloak hostnames.

cnameIgnoreExceptions:
  Boolean
Default value:
  true
Description:
  Whether to bypass the uncloaking of network requests
  which were excepted by filters/rules. This is
  necessary so as to avoid undue breakage by having
  exception filters being rendered useless as a result
  of CNAME-uncloaking.
  For example, `google-analytics.com` uncloaks to
  `www-google-analytics.l.google.com` and both hostnames
  appear in Peter Lowe's list, which means exception
  filters for `google-analytics.com` (to fix site
  breakage) would be rendered useless as the uncloaking
  would cause the network request to be ultimately
  blocked.
2019-12-01 12:05:49 -05:00
Raymond Hill
e98a4b1ace
Discard :: from parsed hosts files
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/800
2019-12-01 09:15:25 -05:00
Raymond Hill
0356e91ccb
Remove no longer used property 2019-12-01 09:01:20 -05:00
Raymond Hill
a16e4161de
Fine tune hostname uncloaking through CNAME-lookup
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/780

Related commit:
- https://github.com/gorhill/uBlock/commit/3a564c199260

This adds two new advanced settings:

- cnameIgnoreRootDocument
  - Default to `true`
  - Tells uBO to skip CNAME-lookup for root document.

- cnameReplayFullURL
  - Default to `false`
  - Tells uBO whether to replay the whole URL or just
    the origin part of it.
    Replaying only the origin part is meant to lower
    undue breakage and improve performance by avoiding
    repeating the pattern-matching of the whole URL --
    which pattern-matching was most likely already
    accomplished with the original request.

This commit is meant to explore enabling CNAME-lookup
by default for the next stable release while:

- Eliminating a development burden by removing the
  need to create a new filtering syntax to deal with
  undesirable CNAME-cloaked hostnames

- Eliminating a filter list maintainer burden by
  removing the need to find/deal with all base
  domains which engage in undesirable CNAME-cloaked
  hostnames

The hope is that the approach implemented in this
commit should require at most a few unbreak rules
with no further need for special filtering syntax
or filter list maintance efforts.
2019-11-23 13:07:23 -05:00
Raymond Hill
1b068c15fb
Fix token array being too small for very long URL
Related feedback:
- https://www.reddit.com/r/uBlockOrigin/comments/dzw57l/

Each token requires two slots in the token indices
array. This commit fixes uBO breaking when dealing
with very long URLs with lot of distinct tokens in
them.
2019-11-22 23:51:39 -05:00
Raymond Hill
68e1b58bb6
Trim trailing spaces from string values in advanced settings 2019-11-20 11:45:10 -05:00
Raymond Hill
563aed0d93
Code review for dns lookup code
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/780

- Handle DNS lookup failure

- Skip DNS lookup for non network-based URLs

- Benchmark code to be able to provide an estimate
  based on objective measurements regarding added
  overhead when DNS lookup is enabled
  (quick answer: a complete non-issue)
2019-11-20 10:45:17 -05:00
Raymond Hill
3a564c1992
Add ability to uncloak CNAME records
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/780

New webext permission added: `dns`, which purpose is
to allow an extension to fetch the DNS record of
specific hostnames, reference documentation:

https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/dns

The webext API `dns` is available in Firefox 60+ only.

The new API will enable uBO to "uncloak" the actual
hostname used in network requests. The ability is
currently disabled by default for now -- this is only
a first commit related to the above issue to allow
advanced users to immediately use the new ability.

Four advanced settings have been created to control the
uncloaking of actual hostnames:

cnameAliasList: a space-separated list of hostnames.
Default value: unset => empty list.
Special value: * => all hostnames.
A space-separated list of hostnames => this tells uBO
to "uncloak" the  hostnames in the list will.

cnameIgnoreList: a space-separated list of hostnames.
Default value: unset => empty list.
Special value: * => all hostnames.
A space-separated list of hostnames => this tells uBO
to NOT re-run the network request through uBO's
filtering engine with the CNAME hostname. This is
useful to exclude commonly used actual hostnames
from being re-run through uBO's filtering engine, so
as to avoid pointless overhead.

cnameIgnore1stParty: boolean.
Default value: true.
Whether uBO should ignore to re-run a network request
through the filtering engine when the CNAME hostname
is 1st-party to the alias hostname.

cnameMaxTTL: number of minutes.
Default value: 120.
This tells uBO to clear its CNAME cache after the
specified time. For efficiency purpose, uBO will
cache alias=>CNAME associations for reuse so as
to reduce calls to `browser.dns.resolve`. All the
associations will be cleared after the specified time
to ensure the map does not grow too large and too
ensure uBO uses up to date CNAME information.
2019-11-19 12:05:33 -05:00
Raymond Hill
eec31fca8b
Save magic compiled/selfie format values in cache storage
Related issue:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1588916

Due to browser behavior changes during development,
uBO can end up using obsolete cached compiled filter
lists or selfie.

Saving magic format values in the cache storage
itself ensure uBO will properly detect actually
obsolete compiled lists/selfie.
2019-11-14 08:22:28 -05:00
Raymond Hill
e2fdc1b94b
Support keyboard shortcut to open popup panel
Related discussion:
- https://www.reddit.com/r/uBlockOrigin/comments/dt47s0/
2019-11-09 09:53:31 -05:00
Raymond Hill
7bf5ac0ca2
Code review of commit 4b34d29384
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/778

Related commit:
- 4b34d29384

Mind that `report-uri` or `report-to` could be
used somewhere in a hostname.
2019-11-09 07:32:19 -05:00
Raymond Hill
4b34d29384
Fix regex used to detect forbidden CSP directives
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/778
2019-11-09 06:59:59 -05:00
Raymond Hill
067ef5843c
Ensure that typeof of href attribute is string
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/777
2019-11-08 09:30:59 -05:00
Raymond Hill
ffae19270f
Coallesce mousemove events
Related commit:
- d1995778ff

Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/615
2019-11-06 07:01:13 -05:00
Raymond Hill
d1995778ff
Allow element picker dialog to be moved around
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/615

There is a grab area under the text area, to be used
to move the dialog around.
2019-11-05 12:03:48 -05:00
Raymond Hill
522249bcb5
Fix test against opener tab id in popup filtering code
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/774

Regression from:
- f204d24bf4
2019-11-04 13:34:44 -05:00
Raymond Hill
ec5191004c
Use encodeURIComponent instead of btoa
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/772
2019-11-04 13:12:40 -05:00
Raymond Hill
da253bf80c
Use type="search" for search input fields
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/768

So that the input fields can gain extra built-in
browser widgets useful in search fields.
2019-11-03 13:14:29 -05:00
Raymond Hill
085a8cdbcc
Fine tune cosmetic filtering badge-related code
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/756

As per feedback:
- https://github.com/uBlockOrigin/uBlock-issues/issues/756#issuecomment-549128106
2019-11-03 09:38:36 -05:00
Raymond Hill
571db71318
Fine tune cosmetic filtering badge-related code
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/756

As per various feedbacks:

Added an advanced setting to keep the original behavior,
which can be potentially costly CPU-wise on some sites:

    popupCosmeticFilterBadgeSlow

Default to `false`. Set to `true` to restore original
method of surveying the number of elements hidden as
a result of applying cosmetic filtering.

As suggested by <https://github.com/gwarser>, skip
descendant of nodes which have been found to be a
match in order to potentially increase the number
of nodes which can be surveyed in the alloted time.
2019-11-02 19:03:07 -04:00
Raymond Hill
4afc0764d2
Fix logic mistake in last commit
Related commit:
- 6d935c8925

Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/756
2019-11-02 11:45:18 -04:00
Raymond Hill
6d935c8925
Bail out when counting hidden elements is too expensive
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/756

When trying the number of hidden elements as a result of
cosmetic filtering for popup panel badge purpose, the
code will bail out if this takes too long, and in such
case the badge will be set to `?`, meaning the number
of hidden elements is undetermined.
2019-11-02 09:16:23 -04:00
Raymond Hill
8acc39581c
Fine tune script tags survey scriptlet
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/756

The code used to count expensive-to-survey particular
inline javascript occurrences will be executed if and
only if no other script tags have been found in the
DOM. This is acceptable since the badge count is to be
deemed approximate (as per documentation).
2019-11-01 14:28:15 -04:00
Raymond Hill
987c9c1a21
Fix on-demand no-cosmetic-filtering badge when generichide in use
Related feedback:
- c090d2fde4 (commitcomment-35767596)

Mind that there might not be selectors to match as a
result of `generichide` or `no-cosmetic-filtering`.
2019-11-01 14:01:30 -04:00
Raymond Hill
c090d2fde4
Count hidden elements on-demand only in popup panel
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/756

The badge value for the no-cosmetic-filtering
switch will be evaluated on-demand only, when
the user hover over the switch with the mouse
cursor.

For touch screen displays, a tap on the switch
will cause the badge to be rendered if not
already done, otherwise this will toggle the
switch as usual.
2019-11-01 12:32:34 -04:00