1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-09-15 07:22:28 +02:00
Commit Graph

2865 Commits

Author SHA1 Message Date
Raymond Hill
0f19dfde38
Avoid or defer writing back to cache storage at launch
The readTime property is unused for compiled or selfie
assets, and thus writing back to storage to persist
this property is useless for those assets, and an undue
overhead when reading such assets, especially at launch
time.

Assets are always loaded from their compiled or selfie
counterparts at launch.

This commit will prevent those unnecessary storage
write operations.
2019-10-15 11:42:43 -04:00
Raymond Hill
f117c280d0
Fix minor bugs spotted during code review 2019-10-14 09:03:51 -04:00
Raymond Hill
79b3b1921e
Import translation work from https://crowdin.com/project/ublock 2019-10-07 08:28:56 -04:00
Raymond Hill
01a4060d2c
Import translation work from https://crowdin.com/project/ublock 2019-10-03 12:44:45 -04:00
Raymond Hill
5a5523c0b5
Remove stats button from logger
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/741

The feature will be released in the future when
it works as I intend for it to work rather than
being a featureless bare-bone version.
2019-10-03 12:32:27 -04:00
Raymond Hill
bf697f344a
Log procedural cosmetic exception filters
Related issue:
- https://github.com/gorhill/uBlock/issues/127

Procedural cosmetic exception filters were the
last class of cosmetic exception filters not
being reported in the logger; this commit fixes
this.

Additionally, ensure that a single DOM listener
can't prevent other listeners from being
processed by throwing an exception. Such approach
would have prevented regression leading to
emergency release 1.22.4:
- https://github.com/gorhill/uBlock/releases/tag/1.22.4
2019-09-30 18:21:24 -04:00
Raymond Hill
7ac908a3f8
Fix regression in logger's reverse-lookup of filters
Related commit:
- e1d75ee602
2019-09-30 11:41:43 -04:00
Raymond Hill
e1d75ee602
Prevent reverse-lookup from finding badfilter-ed filters
This could occur when clicking old entries in the logger
which no longer matched the internal state of uBO.

Related feedback:
- https://github.com/MajkiIT/polish-ads-filter/issues/14768#issuecomment-536006312
2019-09-30 08:53:02 -04:00
Raymond Hill
fc277cb16b
Import translation work from https://crowdin.com/project/ublock 2019-09-30 07:56:34 -04:00
Raymond Hill
3f074d7908
Use self when testing for vAPI presence 2019-09-30 07:50:35 -04:00
Raymond Hill
a8df19fee4
Rename register-like variables
Use leading `$` instead of trailing `$` to denote
register-like variables, this conveniently allows
to group them together in the debugger.
2019-09-29 13:21:09 -04:00
Raymond Hill
bf99623a54
Add sanity checks
In rare circumstances, it's possible the content
script lose access to the background page, best
to check against this to avoid spurious console
errors.
2019-09-29 12:26:58 -04:00
Raymond Hill
e94024d350
Reduce memory usage in staticExtFilteringEngine.HostnameBasedDB
Using pairs of integers allows the use of a
single integer-only array to store lists of
string indices associated to a specific
hostname.

Memory usage of instances of HostnameBasedDB
as per Chromium's heap snaphshot (bytes):

Before:
    2,459,256 => specific cosmetic filters
      944,152 => scriptlet filtering
          736
    ---------
    3,404,144

After:
    1,947,448 => "
      757,936 => "
          632
    ---------
    2,706,016

Ultimately, using 2 integers for each entry
instead of a single one is still worth it
because this allows the use of one single
integer-only array instead of having to use
an array of arrays for hostnames which have
multiple entries.
2019-09-28 13:36:07 -04:00
Raymond Hill
4bf6503f0a
Store csp= filters into main data structure
This commits make it so that `csp=` filters
are now stored in the same data structures as
all other static network filters rather than
being stored in a separate one.

This internal change is motivated by the wish
to bring session filters to the static network
filtering engine, as has already been done for
the static extended filtering engine in the
following commit:

59c9a34d34
2019-09-28 11:30:26 -04:00
Raymond Hill
efa4ff3bcf
Code review re. dynamically loaded vapi-client-extra.js
Related commit:
- 87d0e456f1

Ensure that the code which depends on extending
`vapi-client.js` is ready to deal with
`vapi-client-extra.js` failing to load.
2019-09-26 15:57:55 -04:00
Raymond Hill
7912e919b6
Code review of session filters commit
Related commits:
- 46d36cb0b0
- 59c9a34d34
2019-09-26 12:40:56 -04:00
Raymond Hill
16261aa6b5
Minor code review for d6ccc9857d
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/736
2019-09-26 09:25:33 -04:00
Raymond Hill
d6ccc9857d
Fix missing newline in merging of sublists
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/736

Regression from:
- e27328f931
2019-09-26 09:13:50 -04:00
Raymond Hill
46d36cb0b0
Code review of session filters commit
Related commit:
- 59c9a34d34
2019-09-25 11:21:34 -04:00
Raymond Hill
28aee88a7b
Fix regression in logger's summary pane
Related feedback:
- 59c9a34d34 (commitcomment-35226346)
2019-09-25 06:14:43 -04:00
Raymond Hill
59c9a34d34
Add ability to quickly create exceptions in logger
This is a feature under development, hidden behind
a new advanced setting, `filterAuthorMode` which
default to `false`.

Ability to point-and-click to create temporary
exception filters for static extended filters (i.e.
cosmetic, scriptlet & html filters) from within
the summary pane in the logger. The button to
toggle on/off temporary exception filter is
labeled `#@#`.

The created exceptions are temporary and will be
lost when restarting uBO, or manually toggling off
the exception filters.

Creating temporary exception filters does not
cause the filter lists to reloaded, and thus there
is no overhead in creating/removing these temporary
exception filters.
2019-09-24 17:05:03 -04:00
Raymond Hill
f204d24bf4
Match static popup filter against local context
Related feedback:
- https://www.reddit.com/r/uBlockOrigin/comments/d6zbqv/

For static filter `popup` filter purpose, the URL of the
embedded frame from which the popup was launched will
be used in the matching algorithm.
2019-09-23 08:25:23 -04:00
Raymond Hill
1d2b24c79a
Fix erroneous reports of blocked popups in logger
Reported internally by:
- https://github.com/gwarser

This was reproducible at the following link when
`ping`requests were blocked:
- https://testpages.adblockplus.org/en/filters/ping
2019-09-22 09:19:57 -04:00
Raymond Hill
010635acd6
Add support for ping static filter option
Related issue:
- https://github.com/gorhill/uBlock/issues/1493

Documentation:
- https://help.eyeo.com/adblockplus/how-to-write-filters#type-options

Test page:
- https://testpages.adblockplus.org/en/filters/ping

Additionally, network requests of type `beacon` will
be mapped to `ping` by the static filtering engine.
2019-09-22 09:11:55 -04:00
Raymond Hill
22b390eb00
Fix case of unreported :style filters in logger
As reported by https://github.com/uBlock-user,
adding the two following filters:

example.com##div:style(width: 1016px !important)
example.com##div:style(display: block !important)

The logger would report only one of the filter when
navigating to https://example.com/
2019-09-22 07:51:20 -04:00
Raymond Hill
8c47fa1a3e
Use async/await instead of chained thens 2019-09-21 19:48:02 -04:00
Raymond Hill
eb871ae558
Fix regression in selfie destruction code
Related commit:
- 915687fddb (diff-73ef8c4664f2ec8c02320d50b2908efdR1100-R1113)

Since selfie destruction is now deferred so as to
coallesce burst of call to destroy(), the selfie
load code must mind whether there is a pending
destruction in order to decide whether the
selfie can be safely loaded.

Related feedback:
- 23c4c80136 (commitcomment-35179834)
2019-09-21 19:24:47 -04:00
Raymond Hill
9f825c3059
Do not flush blocked-elements cache at webNavigation time
While testing for the new `elemhide` option using ABP's
test page[1], I found out that the placeholder of the
blocked image on that page was not properly collapsed
by uBO.

The reason was because the page is very simple and
flushing the blocked-elements cache at
webNavigation.onCommitted time was causing the loss
of information collected between
webRequest.onBeforeRequest and
webNavigation.onCommitted, preventing uBO from
properly collapsing the placeholders.

The blocked-elements cache is now flushed
ONLY at webRequest.onBeforeRequest time.

[1] https://testpages.adblockplus.org/en/exceptions/elemhide
2019-09-21 16:42:15 -04:00
Raymond Hill
350e436c08
Remove remnants of chrome references...
... from platform-independent code.

This should complete the de-chromiumification of
uBO. Next step will be to swap the content of the
`platform/chromium` and `platform/firefox`
folders so as to reflect that Firefox is the
natural platform for uBO.
2019-09-21 12:06:57 -04:00
Raymond Hill
23c4c80136
Add support for elemhide (through specifichide)
Related documentation:
- https://help.eyeo.com/en/adblockplus/how-to-write-filters#element-hiding

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

The `elemhide` filter option as per ABP semantic is
now supported. Previously uBO would consider `elemhide`
to be an alias of `generichide`.

The support of `elemhide` is through the convenient
conversion of `elemhide` option into existing
`generichide` option and new `specifichide` option.

The purpose of the new `specifichide` filter option
is to disable all specific cosmetic filters, i.e.
those who target a specific site.

Additionally, for convenience purpose, the filter
options `generichide`, `specifichide` and `elemhide`
can be aliased using the shorter forms `ghide`,
`shide` and `ehide` respectively.
2019-09-21 11:30:38 -04:00
Raymond Hill
4f89a6f89d
Fix missing "Block element" in Firefox's menu
Regression from:
- 58620fb051
2019-09-20 07:51:47 -04:00
Raymond Hill
87d0e456f1
Simplify client messaging code
Little-used code from vapi-client.js has been moved
to vapi-client-extra.js. Given that vapi-client.js
is injected in all web pages, this means less dead
code being injected in all pages.

Swathes of code in vapi-client.js was used only in
a few very specific cases, such as when the logger's
DOM inspector is opened or when the "Filter lists"
pane in the dashboard is opened -- and thus to avoid
that little used code to be loaded in every web page
unconditionally, it has been moved to its own
separate file, vapi-client.extra.js.

vapi-client-extra.js is loaded declaratively or
programmatically only where needed.
2019-09-19 08:31:38 -04:00
Raymond Hill
917f3620e0
Revisit element picker arguments code
No need to store mouse coordinates in background
page, thus no need to post mouse coordinates
information for every click.

Rename/group element picker arguments and popup
arguments separately.
2019-09-18 12:17:45 -04:00
Raymond Hill
022951547c
Work toward modernizing code base: promisification
Swathes of code have been converted to use
Promises/async/await.

Related commits:
- 3224d9b5cc
- 26235d80d0
- 0051f3b5c7
- eec53c0154
- 915687fddb
- 55cc0c6997
- e27328f931
2019-09-18 08:34:55 -04:00
Raymond Hill
78f430678a
Fix needless visual toggling of update/apply buttons 2019-09-18 06:52:10 -04:00
Raymond Hill
3224d9b5cc
Work toward modernizing code base: promisification
Swathes of code have been converted to use
Promises/async/await.

Related commits:
- 26235d80d0
- 0051f3b5c7
- eec53c0154
- 915687fddb
- 55cc0c6997
- e27328f931
2019-09-17 15:15:01 -04:00
Raymond Hill
26235d80d0
Fix regression in importation of custom lists
Reported by:
- https://github.com/uBlock-user:

Imported custom list were incorrectly seen as out of
date immediately after import operation.

Regression from:
- e27328f931

A few lines of code were improperly removed during
refactoring.
2019-09-17 07:44:19 -04:00
Raymond Hill
0051f3b5c7
Work toward modernizing code base: promisification
Swathes of code have been converted to use
Promises/async/await. More left to do.

Related commits:
- eec53c0154
- 915687fddb
- 55cc0c6997
- e27328f931
2019-09-16 16:17:48 -04:00
Raymond Hill
eec53c0154
Work toward modernizing code base: promisification
Swathes of code have been converted to use
Promises/async/await. More left to do.

Related commits:
- 915687fddb
- 55cc0c6997
- e27328f931
2019-09-16 09:45:17 -04:00
Raymond Hill
915687fddb
Work toward modernizing code base: promisification
Also, coallesce calls to selfieManager.destroy() so as
to avoid undue repeated calls to storage deletion of
selfie assets.

Related commit:
- e27328f931
2019-09-15 09:36:50 -04:00
Raymond Hill
55cc0c6997
Fix regression from promisification work
Related commit:
- e27328f931

The regression was preventing the compiled filter
lists from being properly loaded by uBO, thus
always causing a full parsing/compiling at
launch time.
2019-09-15 09:35:04 -04:00
Raymond Hill
be1d1b3eee
Import translation work from https://crowdin.com/project/ublock 2019-09-15 08:10:31 -04:00
Raymond Hill
e27328f931
Work toward modernizing code base: promisification
Swathes of code have been converted to use
Promises/async/await. More left to do.

In the process, a regression affecting the fix to
<https://github.com/uBlockOrigin/uBlock-issues/issues/682>
has been fixed.
2019-09-15 07:58:28 -04:00
Raymond Hill
97d6d5028b
Fix mishandling of procedural cosmetic exceptions in logger
Issue reported by @uBlock-user in team channel.

Creating cosmetic procedural exception filters was
causing `cosmetic-logger.js` scriptlet to throw at
and thus further breaking the logging of cosmetic
filters overall.
2019-09-12 13:05:41 -04:00
Raymond Hill
e393a52442
Fix icon title always showing (0) when badge is disabled
Related feedback:
- https://www.reddit.com/r/uBlockOrigin/comments/d33d37/
2019-09-12 12:26:09 -04:00
Raymond Hill
b5c1efc7f5
Informal code review toward ES6 2019-09-11 08:08:30 -04:00
Raymond Hill
93f438f55e
Add advanced setting for extension reload on update
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/717

Related feedback:
- https://github.com/uBlockOrigin/uBlock-issues/issues/717#issuecomment-530275655

New advanced setting: `extensionUpdateForceReload`

Default value: `false`

If set to `true`, the extension will unconditionally reload
when an update is available; otherwise the extension will
reload only when being explicitly disabled then enabled, or
when the browser is restarted.
2019-09-11 08:00:55 -04:00
Raymond Hill
7e8822cfc5
Import translation work from https://crowdin.com/project/ublock 2019-09-10 16:44:14 -04:00
Raymond Hill
1e7e6f86a6
Reuse existing Set/Map when calling scriptletFilteringEngine.retrieve
Reuse permanent instances instead. The trailing `$` is
used to denote these variables are register-like
instances, i.e. their content is valid only for the
duration of the call. (From now on I will use this
convention throughout the code base.)
2019-09-10 13:59:28 -04:00
Raymond Hill
a73dd0a9f2
Fix entity-based lookup in html & scriptlet filtering
Entity-based filters where not properly looked-up if
they used subdomains. Example:

- `example.*##^script` => ok

- `www.example.*##^script` => failed on `https://www.example.com/`
2019-09-10 10:51:34 -04:00
Raymond Hill
4792e0e291
Coalesce tab reloads in burst "relax blocking mode" ops
Quickly firing "Relax blocking mode" commands will
cause the tab to reload only once.
2019-09-08 12:52:28 -04:00
Raymond Hill
3eeaba45d9
Cherry-picked ac7825c789 2019-09-07 08:31:32 -04:00
Raymond Hill
c8c2e11d09
Prevent reload if updated version is higher than current
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/717

Related feedback:
- https://github.com/uBlockOrigin/uBlock-issues/issues/717#issuecomment-528921730
2019-09-06 13:03:06 -04:00
Raymond Hill
8f319e3ceb
Import translation work from https://crowdin.com/project/ublock 2019-09-06 11:48:01 -04:00
Raymond Hill
bcf5ac1fee
Add advanced setting to control logger popup type
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/663

The advanced setting `loggerPopupType` has been added, to
control the type of window to be used when the logger is
launched as a separate window.

The default value is `popup`, it can be changed to any of
the values documented at:

https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/windows/CreateType
2019-09-06 11:41:07 -04:00
Raymond Hill
aee6b2d1cb
Fix regression in filter compilation in element picker
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/715

Regression from fix to issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/710
2019-09-02 08:43:49 -04:00
Raymond Hill
ca9b29c7ec
Distinguish between priviledge and unprivileged messages
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/710

Messages from unprivileged ports (i.e. from content scripts)
are no longer relayed to message handlers which are to be
strictly used to execute privileged code.

The last remaining case of unprivileged messages which
should be converted into a privileged ones will be taken
care of when the following issue is fixed:
- https://github.com/gorhill/uBlock/issues/3497
2019-09-01 12:43:12 -04:00
Raymond Hill
ed2fc4a7bb
Import translation work from https://crowdin.com/project/ublock 2019-08-30 09:29:11 -04:00
Raymond Hill
1d805fb9da
Add support for !#if false in list directive processor
To more easily comment out blocks of filters.
2019-08-25 09:08:41 -04:00
Raymond Hill
e0b8cf24d1
Clear internal cache when loading redirect rules
Related commit:
- 3e5c9e00ab

This fix a regression: newly added redirect rules
could end up not being taken into account unless
uBO was restarted.
2019-08-24 13:48:50 -04:00
Raymond Hill
dee52eef47
Import translation work from https://crowdin.com/project/ublock 2019-08-23 11:35:50 -04:00
Raymond Hill
9f7e385a5c
Code review fix re. max string length in bidi-trie
Related commit:
- fb4e94f92c

A bidi-trie can't store strings longer than 255 characters
because the string segment lengths are encoded into a single
byte. This commit ensures only strings smaller than
256 characters are stored in the bidi-tries.
2019-08-23 11:30:10 -04:00
Raymond Hill
fb4e94f92c
Fix spurious 256-char limit for filters stored in bidi-trie
Plain filters can be any length, while the bidi-trie was
assuming max length of 256. The origin of this error
is from when the bidi-trie code was originally imported
from the hntrie code as start to develop bidi-trie.

The erroneous code could cause issue when the following
conditions were met:
- Plain filter longer than 256 characters
- Free space in bidi-trie's character buffer was less
  than 256 bytes

Likely a rare occurrence, but some filter lists do contains
long plain filters, for example:

    https://gitlab.com/curben/urlhaus-filter/raw/master/urlhaus-filter.txt

Related feedback:
- https://www.reddit.com/r/uBlockOrigin/comments/cs1y26/
2019-08-22 17:11:49 -04:00
Raymond Hill
708e5004e8
Fix badly computed output size in µBlock.base64.encode()
This bug could cause losing 1 to 3 bytes of information
dropped from various internal buffers at encoding time.

Possibly related feedback:
- https://www.reddit.com/r/uBlockOrigin/comments/cs1y26/
2019-08-22 09:17:19 -04:00
Raymond Hill
e735cd6a3f
Import translation work from https://crowdin.com/project/ublock 2019-08-21 10:33:16 -04:00
Raymond Hill
5ad809c07d
Code review color badge code
Related commit:
- 07c950f1e5

Cache [blocking mode, color] pair for fast
lookup in subsequent calls.
2019-08-19 09:00:53 -04:00
Raymond Hill
9a9a43d0f6
Import translation work from https://crowdin.com/project/ublock 2019-08-18 10:47:51 -04:00
Raymond Hill
bf3c92574e
Add support for special exception filter #@#+js()
The purpose is to wholly disable scriptlet injection
for a given site without having to create exceptions
for all matching scriptlet injection filters.

The following exception filter will cause scriptlet
injection to be wholly disable for `example.com`:

    `example.com#@#+js()`

Or to disable scriptlet injection everywhere:

    `#@#+js()`

The following form is meaningless and will be
ignored:

    `example.com##+js()`
2019-08-17 08:38:48 -04:00
Raymond Hill
6c73bd78f4
Fix regression when generating data URI in redirect engine
Related feedback:
- https://www.reddit.com/r/uBlockOrigin/comments/cpxm1v/

Put back erroneously removed code which enable to
generate a `data` URI from already encoded resources.
2019-08-16 13:45:07 -04:00
Raymond Hill
d67340f14d
Add ability to escape comma in a scriptlet's list of arguments
An instance of `\,` will not be interpreted as an arguments
separator -- thus allowing the use of commas inside
argument values.
2019-08-14 11:02:01 -04:00
Raymond Hill
68ae847ba3
Add support for AdGuard's mp4 filter option
Related discussion:
- https://github.com/uBlockOrigin/uBlock-issues/issues/701#issuecomment-520884196

The `mp4` filter option will be converted to `redirect=noopmp4-1s`
internally, and `media` type will be assumed.
2019-08-13 12:30:11 -04:00
Raymond Hill
52925ba2f9
Support disabling advanced setting cacheControlForFirefox1376932
Related feedback:
- https://github.com/uBlockOrigin/uBlock-issues/issues/229#issuecomment-520810161

Setting `cacheControlForFirefox1376932` to `unset` will
prevent modification of the `Cache-Control` header.
2019-08-13 08:49:37 -04:00
Raymond Hill
3e5c9e00ab
Add support for AdGuard's empty option
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/701

The filter option `empty` is converted to `redirect=empty`
by uBO internally; however unlike when the `redirect=`
option is used expressly, the `empty` option does not
require a resource type.

When `empty` is used, only network requests which are meant
to return a text response will be redirected to an empty
response body by uBO -- so `empty` will not work for
resources such as images, media, or other binary resources.
2019-08-13 08:16:21 -04:00
Raymond Hill
2c39a1af02
Extend pseudo-elements support byond ::before/::after
Related feedback:
- https://github.com/uBlockOrigin/uAssets/issues/6069#issuecomment-520254292
2019-08-11 16:32:49 -04:00
Raymond Hill
ffa6f6c8f9
Import translation work from https://crowdin.com/project/ublock 2019-08-11 14:00:53 -04:00
Raymond Hill
07c950f1e5
Review icon badge color management
Related commit & feedback:
- 7ff750eaf6

The color value for the icon badge is now
"attached" to the blocking profile value.
Additionally, as per feedback, `3p` rules
will be relaxing before master JavaScript
switch rules.
2019-08-11 13:55:39 -04:00
Raymond Hill
7ff750eaf6
Reflect blocking mode in badge color of toolbar icon
Related feedback:
- https://www.reddit.com/r/uBlockOrigin/comments/cmh910/

Additionally, the `3p` rule has been made distinct from
`3p-script`/`3p-frame` for the purpose of
"Relax blocking mode" command.

The badge color will hint at the current blocking mode.
There are four colors for the four following blocking
modes:
- JavaScript wholly disabled
- All 3rd parties blocked
- 3rd-party scripts and frames blocked
- None of the above

The default badge color will be used when JavaScript is not
wholly disabled and when there are no rules for `3p`,
`3p-script` or `3p-frame`.

A new advanced setting has been added to let the user choose
the badge colors for the various blocking modes,
`blockingProfileColors`. The value *must* be a sequence of
4 valid CSS color values that match 6 hexadecimal digits
prefixed with`#` -- anything else will be ignored.
2019-08-10 10:57:24 -04:00
Raymond Hill
5e1f4d7906
Invalidate browser's memory cache after using element picker
Related reports:
- https://www.reddit.com/r/uBlockOrigin/comments/cj7g7m/
- https://www.reddit.com/r/uBlockOrigin/comments/cnq0bi/

The browser cache will be invalidated only when creating
static network filter through the element picker.

As per @gwarser's arguments in favor of implementing
usage of webRequest.handlerBehaviorChanged():
https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/webRequest/handlerBehaviorChanged
2019-08-09 09:31:20 -04:00
Raymond Hill
7ac7b027f4
Restore ability to redirect xhr to image resources
The ability to redirect xmlhttprequest to binary
resources was lost when redirectable/injectable
resources became immutable in commit
152cea2dfe.

This commit restores the ability to redirect a
xmlhttprequest to a binary resource by making
it possible to derive a data: URI from the
content of binary resources such as images.

Addtionally a redirect to a data: URI can be
forced by prefixing the resource token with `%`.
This is a non-official feature at this point,
i.e. it could be removed at any time.
2019-08-06 10:51:24 -04:00
Raymond Hill
7a3578ebcc
Import translation work from https://crowdin.com/project/ublock 2019-08-03 10:31:04 -04:00
Raymond Hill
aa73f292ec
Add new static network filter option: redirect-rule=
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/310

The purpose of this new option is to add the ability
to create standalone redirect rule without being forced
to create a block filter (a corresponding block filter
is always created when using the `redirect=`).

Additionally:

The syntax `*$redirect=token,...` is now supported, there
is no need to "trick" the filter parser with
`*/*$redirect=token,...` in order to create redirect rules
which are meant to match all paths.

Filters of the form `|http*://` will be normalized into
two corresponding filters `|https://` and `|http://` so as
to reduce the number of filters in the buckets of
untokenizable filters.
2019-08-03 10:18:47 -04:00
Raymond Hill
c93b2910ba
Import translation work from https://crowdin.com/project/ublock 2019-07-30 12:30:24 -04:00
Raymond Hill
104b222275
Revisit fix to https://github.com/uBlockOrigin/uBlock-issues/issues/627
The previous fix led to a regression. Related ffedback:
- 8d136ec2d5 (commitcomment-34460854)
2019-07-30 12:27:09 -04:00
Raymond Hill
f2ea0c6900
Import translation work from https://crowdin.com/project/ublock 2019-07-26 09:59:59 -04:00
Raymond Hill
048bfd251c
Add ability to bypass browser cache when fetching a resource
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/682#issuecomment-515197130

The following advanced setting has been added:

    updateAssetBypassBrowserCache

Default to `false`. If set to `true`, uBO will ensure the
browser cache is bypassed when fetching a remote resource.

This is for the convenience of filter list maintainers who
may want to test the latest version of their lists when
fetched from their remote location.
2019-07-26 09:52:11 -04:00
Raymond Hill
8d136ec2d5
Ignore pseudo-elements when querying selectors in element picker
Related issue:
- https://github.com/gorhill/uBlock/issues/2515
2019-07-26 09:24:34 -04:00
Raymond Hill
08c3f06160
Log :style(...) cosmetic filters only when there is a match
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/627
2019-07-23 11:42:04 -04:00
Raymond Hill
075d78e8e6
Remove trailing commas in function parameter lists
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/681
2019-07-22 17:38:23 -04:00
Raymond Hill
47cfba1551
Manually import df97249715 from 1.21.4
Related commit:
- https://github.com/gorhill/uBlock/commit/df972497156e
2019-07-22 06:30:00 -04:00
Raymond Hill
716aae4236
Reverting fix to https://github.com/gorhill/uBlock/issues/3639
Related feedback:
- a54cb2e38f (commitcomment-34387041)

Regression from converting uBO resources into
immutable resources. This affects only Chromium-based
browsers.

This is a quick fix for the dev build, to at least unbreak
the reported case.

I need to research whether the root issue (conflict with HTTPS-E)
is still occurring, and if so the fix is not trivial: I will need
to add code to uBO to fetch and convert binary data into `data:`
URIs.
2019-07-21 20:53:42 -04:00
Raymond Hill
066440534d
Prevent popup panel to close when forcing a tab reload
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/672

Additionally, this commit add the ability to press F5 to
force a reload while the popup panel is opened.
2019-07-21 11:50:15 -04:00
Raymond Hill
48347897ad
Remove obsolete ublock-resources-related code
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/679
2019-07-21 11:00:14 -04:00
Raymond Hill
e1dd7f7043
Ensure toolbar icon reflect updated whitelist directives
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/680

Opportunistically, vAPI.tabs has been refactored toward
ES6 syntax.
2019-07-21 10:48:44 -04:00
Raymond Hill
ecd81183b1
Fix thrown exception in onHeadersReceived listener
Regression from:
- https://github.com/gorhill/uBlock/commit/ae56c4dfe855
2019-07-19 10:02:27 -04:00
Raymond Hill
10fe9fe656
Allow setting assetsBootstrapLocation from admin settings
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/666
2019-07-18 10:53:08 -04:00
Raymond Hill
941f57e8f4
Import translation work from https://crowdin.com/project/ublock 2019-07-17 11:17:37 -04:00
Raymond Hill
3b0d214633
Mind escape sequences when validating :style filters
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/668
2019-07-13 07:49:07 -04:00
Raymond Hill
8d8336ffae
Remove useless return statement 2019-07-12 09:13:10 -04:00
Raymond Hill
d6927cf1fe
Ensure all members are initialized before loading selfie
Theoretically, if a selfie is loaded from corrupted
storage resulting in a thrown exception from the
constructor, this would cause an improperly initialized
HostnameBasedDB instance and overall potentially a
broken uBO.

Related feedback:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1543880#c7
2019-07-12 09:05:42 -04:00
Raymond Hill
ce644c5960
Remove code unused in next release
Since https://github.com/uBlockOrigin/uBlock-issues/issues/156
won't be fixed in next release, no need to ship
with code which will be unused, and anyways only once
the fix is worked on will it be clear exactly what needs
to be used by scriptlets to deal harmoniously with
property listener collisions.
2019-07-11 10:17:06 -04:00
Raymond Hill
9ef06da310
Minor code review re. https://github.com/uBlockOrigin/uBlock-issues/issues/658 2019-07-11 09:50:12 -04:00
Raymond Hill
80402d202a
Import translation work from https://crowdin.com/project/ublock 2019-07-10 17:29:48 -04:00
Raymond Hill
874e92af2d
Fix regression in URL rules validation
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/665

Regression:
- 2f63fb3fd4
2019-07-10 17:24:01 -04:00
Raymond Hill
b54522caa1
[scriptlet engine] Mind old scriptlet names not using .js
Related commit:
- 5552d6717d
2019-07-09 11:36:42 -04:00
Raymond Hill
5c449f59f2
[redirect engine] Use shorter name as the official name
- nobab.js => bab-defuser.js
- nofab.js => fuckadblock.js-3.2.0
2019-07-09 11:04:12 -04:00
Raymond Hill
fee217c59c
Fix regression introduced in 2f63fb3fd4
Related feedback:
- 2f63fb3fd4 (commitcomment-34222571)
2019-07-08 12:33:11 -04:00
Raymond Hill
2f63fb3fd4
Prevent adding known invalid URL-based rules
Related discussion:
- https://github.com/uBlockOrigin/uBlock-issues/issues/662#issuecomment-509220702

Currently, `doc` (aka `main_frame`) rules are not
evaluated to decide whether a network request must
be blocked or not, by design. This commits adjust
uBO's UI to account for this.
2019-07-08 10:49:53 -04:00
Raymond Hill
e55cae6232
Fine tune new resources-related code
Make sure the parser is safely compatible with old
resources format -- for those users still using
custom resources (via `userResourcesLocation`).

Prepare code for future fix to
<https://github.com/uBlockOrigin/uBlock-issues/issues/156>:

This commit introduces a new private Map() object,
`uBOSafe`, accessible by all injected scriptlets. This
private safe can be used to store data which can be shared
with different scriptlets. The idea is for scriptlets to
use that safe to graciously deal with the need to install
multiple listeners for the same property.
2019-07-08 08:56:36 -04:00
Raymond Hill
da4c4ded8d
Add a way to reload resources in dev build
Since resources are now immutable, by default they are
only compiled once each time uBO updates to a new
version. However I need a way to force a re-compiling
of the resource in the dev build. This commit adds code
to invalidate the resources selfie when forcing the
update of any filter list.
2019-07-08 08:41:28 -04:00
Raymond Hill
ad9b34bc7a
Code review of 9d1913a16e
Also eat backslash for `\\`, to allow searching for
literal `\n`, `\t`.
2019-07-07 07:52:37 -04:00
Raymond Hill
47a5caef54
Fix last newline not being automatically appended
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/657
2019-07-07 06:57:30 -04:00
Raymond Hill
9d1913a16e
Eat backslashes only for common control characters
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/658
2019-07-07 06:29:14 -04:00
Raymond Hill
2acaf3c433
Fix background color of previewed image in logger
Related feedback:
- https://www.reddit.com/r/uBlockOrigin/comments/c9u5xy/
2019-07-06 17:26:35 -04:00
Raymond Hill
6d2f66fef6
Import translation work from https://crowdin.com/project/ublock 2019-07-06 12:56:27 -04:00
Raymond Hill
6f5aa947fb
Finalize converting resources.txt into immutable resources
With hindsight, I revised decisions made earlier during
this development cycle:

Un-redirectable scriptlets have been removed from
/web_accessible_resources and instead put in the new
/assets/resources/scriptlets.js, which contains all
scriptlets used for web page injection purpose.

uBO will no longer fetch a remote version of built-in
resources.

Advanced setting `userResourcesLocation` will still be
honoured by uBO, and if set, will be fetched every
time at least one asset is updated.
2019-07-06 12:36:28 -04:00
Raymond Hill
ae56c4dfe8
Fix whitelist status evaluation of tabless network requests
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/651

The `behnind-the-scene` context was wrongly used to
evaluate the whitelist status of the context of tabless
network requests. The document origin must be used
instead when it's available.

Additionally, much code has been revisited for better
ES6 syntax compliance.
2019-07-05 17:44:08 -04:00
Raymond Hill
9693d07a6d
Code review of https://github.com/gorhill/uBlock/commit/f930da7ad64a 2019-07-05 12:33:14 -04:00
Raymond Hill
f930da7ad6
Fix regression of reverse-lookup of scriptlet filters in logger
Related commit:
- 5552d6717d
2019-07-05 11:44:40 -04:00
Raymond Hill
e107b6bcf1
Fix typo in comment 2019-07-05 10:32:19 -04:00
Raymond Hill
5552d6717d
Implement scriptlet token normalization
The goal is to be able to specify a scriptlet token
without the `.js` part at the end, because that part
is essentially redundant with the `+js` part of
the syntax.

When the next stable release is in widespread use
(to determine), scriptlet tokens will have to be
specified without the `.js` part, and with this
commit the logger will already report the normalized
version of scriptlets.

Eventually, when the migration to sans-`.js` is
complete (also to determine), the internal
normalization of the token will be removed and this
will become official syntax.

Filter list maintainers will have to mind that
uAssets is becoming in use beyond uBO (i.e. Brave)
when skipping the `.js` part -- hopefully Brave will
go along with the change here, which is to remove a
bit of tediousness for filter list maintainers.
2019-07-05 10:10:59 -04:00
Raymond Hill
6220e1d3eb
Add missing newline 2019-07-05 08:22:26 -04:00
Raymond Hill
3e53963be3
Fix window.open-defuser
Matching logic has been erronesouly reverse.
2019-07-05 07:59:02 -04:00
Raymond Hill
a992875c94
Save only modified immediate hidden settings 2019-07-05 07:33:09 -04:00
Raymond Hill
b3ea68a08d
Import translation work from https://crowdin.com/project/ublock 2019-07-04 15:50:20 -04:00
Raymond Hill
1fb9845c35
Remove useless code 2019-07-04 14:10:23 -04:00
Raymond Hill
f9e680f111
Convert more resources as immutable
Related commit:
- 152cea2dfe
2019-07-04 14:08:56 -04:00
Raymond Hill
8e245c8919
Convert more resources as immutable
Related commit:
- 152cea2dfe
2019-07-03 19:26:09 -04:00
Raymond Hill
0ba9a35818
Convert more resources as immutable
Related commit:
- 152cea2dfe
2019-07-03 14:33:06 -04:00
Raymond Hill
5672f54663
Import translation work from https://crowdin.com/project/ublock 2019-07-03 09:57:04 -04:00
Raymond Hill
152cea2dfe
Refactor management of injectable resources
This is a first step, the ultimate goal is to remove
the need for resources.txt, or at least to reduce to
only hotfixes or for trivial resources targeting very
specific websites.

Most resources will become immutable, i.e. they will
be part of uBO's code base. Advantages include easier
code maintenance (jshint, syntax highlight), and to
make scriptlets more easy to code review by external
parties (for example extension store reviewers).

TODO:

- More scriptlets need to be imported before next
  release.
- Need to make legacy versions of uBO use a legacy
  version of resources.txt, as all the now obsolete
  scriptlets will have to be removed once uBO's
  next release become widespread.
- Possibly need to add code to load binary
  resources so that they can be injected as
  data: URI. So far it's unclear whether this is
  really needed. For example, this would be needed
  if a xmlhttprequest is redirected to an image
  resource.
2019-07-03 09:47:56 -04:00
Raymond Hill
41636c59fb
Strict-block only if match is anchored to end of hostname
As per feedback from filter list maintainers.
2019-07-02 11:56:27 -04:00
Raymond Hill
2e04b75ccf
Import translation work from https://crowdin.com/project/ublock 2019-07-02 09:59:26 -04:00
Raymond Hill
730a83377e
Minor code review re. context menu code
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/151

I have been unsuccessful fixing the above issue, but I will
keep the changes made in the process of trying to fix it.
2019-07-02 09:43:26 -04:00
Raymond Hill
cdd1aac442
Add convenience link to network resources in logger
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/648
2019-06-30 16:15:19 -04:00
Raymond Hill
2bcf671dae
Put back erroneously removed line
Regression from 1dfdc40e09
2019-06-30 12:54:05 -04:00
Raymond Hill
c8860ff61d
Code review of c1bdc123f2 2019-06-30 10:22:06 -04:00
Raymond Hill
1dfdc40e09
Add ability to suspend network request handler at will
This works only for platforms supporting the return of
Promise by network listeners, i.e. only Firefox at this
point.

When filter lists are reloaded[1], there is a small
time window in which some network requests which should
have normally been blocked are not being blocked
because the static network filtering engine may not
have yet loaded all the filters in memory

This is now addressed by suspending the network request
handler when filter lists are reloaded -- again, this
works only on supported platforms.

[1] Examples: when a filter list update session
    completes; when user filters change, when
    adding/removing filter lists.
2019-06-30 10:09:27 -04:00
Raymond Hill
c1bdc123f2
Fix use of sibling-related CSS syntax at prefix position
Related discussion:
- https://www.reddit.com/r/uBlockOrigin/comments/c6iem5/
2019-06-29 14:07:54 -04:00
Raymond Hill
b1ec593b9f
Import translation work from https://crowdin.com/project/ublock 2019-06-29 11:16:25 -04:00
Raymond Hill
cf4345ffc4
Fix some element picker-related issues
Related discussion:
- https://www.reddit.com/r/uBlockOrigin/comments/c5do7w/

Make the element picker better reflect network filters as
parsed by the static network filtering engine. Additionally,
discard single alphanumeric character-based filters.

Related discussion:
- https://www.reddit.com/r/uBlockOrigin/comments/c62irc/

Inject newly created cosmetic filters into the DOM
filterer, in order for these filters to be enforced by
the DOM filterer in subsequent dynamic DOM changes.
2019-06-29 11:06:03 -04:00
Raymond Hill
dba075af59
Import translation work from https://crowdin.com/project/ublock 2019-06-28 06:27:53 -04:00
Raymond Hill
6c34b3c3c9
Use "relax" instead of "toggle"
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/371
2019-06-27 08:16:18 -04:00
Raymond Hill
388e5df5fd
Import translation work from https://crowdin.com/project/ublock 2019-06-27 08:14:48 -04:00
Raymond Hill
a9659d039d
Add missing command in manifest.json 2019-06-26 17:17:41 -04:00
Raymond Hill
f9c9c2cc14
Import translation work from https://crowdin.com/project/ublock 2019-06-26 10:20:31 -04:00
Raymond Hill
693687fd74
Add keyboard support for toggling down blocking profile
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/371

By default, no specific keyboard shortcut is predefined,
this will have to be assigned by the user. The command
name in English is "Toggle blocking profile".

The default behavior is to toggle down according to one
of the following scenarios.

a) If script execution is disabled through the no-scripting
switch, the no-scripting switch will be locally toggled
so as to allow script execution. The page will be
automatically reloaded.

b) If script execution is not blocked but the 3rd-party
script and/or frame cells are blocked, local no-op rules
will be set so as to no longer block 3rd-party scripts
and/or frames. The page will be automatically reloaded.

Given this, it may take more than one toggle down command
to reach the lowest blocking profile, which is one where
JavaScript execution is not blocked and 3rd-party scripts
and frames resources block rules, if any, are bypassed
with local no-op rules.

TODO: At this point, I haven't yet decided whether
toggling from the lowest profile should restore the
original highest blocking profile.
2019-06-26 07:47:14 -04:00
Raymond Hill
d1df2b5e73
Fix merging multiple URls in element picker
Related discussion:
- https://www.reddit.com/r/uBlockOrigin/comments/c5do7w/

Fixed:
- Expect the differ can return the first input as is when
  there is no difference between the two items.
- Better deal with extraneous whitespaces in `srcset`
2019-06-25 17:09:04 -04:00
Raymond Hill
9065bbdd48
Code review of whitelisting-related code
- Use `Map()` instead of `{}` for internal data
  structure
- Export as array of directives instead of as
  a string
2019-06-25 11:57:14 -04:00
Raymond Hill
8e7384ba84
Prevent duplicate inline-script entries in the logger
Related discussion:
- https://www.reddit.com/r/uBlockOrigin/comments/c4340z/filter_problem/ervpjd8/
2019-06-24 11:40:14 -04:00
Raymond Hill
ce94319e86
Import translation work from https://crowdin.com/project/ublock 2019-06-23 08:44:13 -04:00
Raymond Hill
41685f4cce
Replace exec with transpose in procedural filters
The purpose is to avoid having to iterate through
all input nodes at each operator implementation
level. The `transpose` method deals with only one
input node, and the iteration is performed by the
main procedural filtering entry points.

Additionally:
- Add `:spath` to HTML filtering
- Rename `:watch-attrs` to `:watch-attr`
  - `:watch=attrs` is deprecated and will be kept around
    until it is safe to remove it completely
2019-06-23 08:05:53 -04:00
Raymond Hill
570723f795
Import translation work from https://crowdin.com/project/ublock 2019-06-20 14:42:37 -04:00
Raymond Hill
b428a25c3f
Add new procedural operator: :min-text-length(x)
Where `x` is the minimal text length of the subject
DOM element. DOM elements whose text length is
greater than or equal to `x` will be selected.

The original rationale for such procedural cosmetic
operator[1] is to be able to remove inline script
elements according to a minimum text length using
HTML filtering.

[1] As a result of internal discussion with filter
    list maintainers @ uAssets.
2019-06-20 14:11:54 -04:00
Raymond Hill
822e0a133d
Provide visual feedback for invalid entries in "My rules"
Related issue:
- https://github.com/gorhill/uBlock/issues/1039
2019-06-19 18:28:44 -04:00
Raymond Hill
be2a950541
Code review of HNTrie/staticNetFilteringEngine
- Remove HNTrieContainer class from global context by
  storing it as a property of µBlock.

- Use block scope to isolate HNTrie-related constants
  from global context.

- Prevent filters which are pure IP address from
  being stored in an HNTrie instance -- as this
  could cause false positives.
2019-06-19 10:00:19 -04:00
Raymond Hill
7303776757
Use async/await in Matrix.benchmark() 2019-06-19 08:37:48 -04:00
Raymond Hill
cfc2ce333d
Implement bidirectional plain-string trie
The bidirectional trie allows storing the right
and left parts of a string into a trie given a
pivot position.

Releated issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/528

Additionally, the mandatory token-at-index-0 rule
for FilterPlainHnAnchored has been lifted, thus
allowing the engine to pick a potentially better token
at any position in the filter string.

***

TODO: Eventually rename `strie.js` to `biditrie.js`.

TODO: Fix dump() method, it currently only show the
      right-hand side of a filter string.
2019-06-18 19:16:39 -04:00
Raymond Hill
7e38391a71
Import new Bosnian translations from https://crowdin.com/project/ublock 2019-06-15 09:38:06 -04:00
Raymond Hill
5c05209e7f
Import translation work from https://crowdin.com/project/ublock 2019-06-14 10:59:07 -04:00
Raymond Hill
2a2faa84a0
Import translation work from https://crowdin.com/project/ublock 2019-06-05 08:19:12 -04:00
Raymond Hill
e9bbc33194
Import translation work from https://crowdin.com/project/ublock 2019-06-03 06:42:02 -04:00
Raymond Hill
2eb9b726a5
Fix generichide not being evaluated for local context
Related issue:
- https://github.com/uBlockOrigin/uAssets/issues/5704
2019-06-03 06:37:39 -04:00
Raymond Hill
bd961364cc
Import new en-GB from https://crowdin.com/project/ublock 2019-05-31 09:30:32 -04:00
Raymond Hill
c312ec2cd5
Import translation work from https://crowdin.com/project/ublock 2019-05-31 09:17:16 -04:00
Raymond Hill
27e8c8d468
Normalize tabless xhr to image/media in onHeadersReceived()
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/610

The service worker-related issue affects both
Chromium/Firefox: the type of resources fetched
from a service worker are uniformly set to
`xmlhttprequest`, hence losing a key piece of
information for the purpose of accurate content
filtering.
2019-05-31 09:02:07 -04:00
Raymond Hill
a691d180f2
Import translation work from https://crowdin.com/project/ublock 2019-05-28 07:25:11 -04:00
Raymond Hill
8828522fe8
Fix errors with cosmetic filter exception in the logger
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/602
2019-05-28 07:21:16 -04:00
Raymond Hill
d99789e107
Import translation work from https://crowdin.com/project/ublock 2019-05-26 08:11:38 -04:00
Raymond Hill
85b89fbe63
Fix broken import-from-file in Whitelist pane
Related discussion:
- https://www.reddit.com/r/uBlockOrigin/comments/bt2d1f/
2019-05-26 08:03:44 -04:00
Raymond Hill
ede233abe7
Import translation work from https://crowdin.com/project/ublock 2019-05-25 10:09:53 -04:00
Raymond Hill
a7bfff03d6
Avoid spurious diff at edit time in "My rules"
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/593

The issue was caused by the lack of empty last line, since
the differ taking into account new line characters.
2019-05-25 10:04:31 -04:00
Raymond Hill
80a8750d35
Select existing "Advanced settings" page if any
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/591

Additionally, I added a link to the logger in the
"About" pane in the dashboard in order to be able
to access the logger without having to go through
the popup panel.
2019-05-25 08:31:06 -04:00
Raymond Hill
fb6d69f543
Discard whole filter with bad csp= content
Related discussion:
- https://www.reddit.com/r/uBlockOrigin/comments/bshn7z/

uBO was just removing the bad option, while the whole
filter needs to be discarded.
2019-05-24 15:41:37 -04:00
Raymond Hill
1e9528e2a6
Fix regression affecting *$csp=-like filters
Related discussion:
- https://www.reddit.com/r/uBlockOrigin/comments/bshn7z/filter_question/

Regression introduced in:
- 3f3a1543ea
2019-05-24 12:15:32 -04:00
Raymond Hill
26708b37c1
Integrate bare-bone filter hit stats in the logger
Related issue:
- https://github.com/gorhill/uBlock/issues/983
- https://github.com/gorhill/uBlock/issues/1353

The current implementation reports statistics for all
static filters, and the presentation/featureset is
intentionally minimal: *Do not open issues about this.*
It's still a work in progress and it will be worked on
slowly and thoughtfully over time and as time allows.

Pausing the logger will not pause the collation of
filter hit statistics, thus it is possible to lower
the logger overhead by pausing logger output without
losing filter hit collation.
2019-05-24 11:18:39 -04:00
Raymond Hill
64636a44cb
Import translation work from https://crowdin.com/project/ublock 2019-05-23 19:35:53 -04:00
Raymond Hill
eef76c49ae
Add a link to the remote asset in asset viewer
The link will be present if and only if the content
of the currently viewed asset has been fetched from
a remote location.
2019-05-23 19:29:59 -04:00
Raymond Hill
294ea41fde
Import emergency fix 5a29a21c81 in dev build 2019-05-23 10:22:51 -04:00
Raymond Hill
1f398134f9
Minor code reivew of 4430ec11e2 2019-05-23 08:15:26 -04:00
Raymond Hill
7b8c087fdd
Start using async/await where it makes sense 2019-05-22 19:23:04 -04:00
Raymond Hill
8d40d41cf7
Import translation work from https://crowdin.com/project/ublock 2019-05-22 18:07:08 -04:00
Raymond Hill
4430ec11e2
Rearrange inner loop of static network filtering engine
The motivations for the re-arrangement:

- Reducing the number of entry points:
  matchStringExactString() has been removed and
  matchString() is simply reused with a modifier parameter
  to enable matching variants.

- Presumption that most matches, if any, occur early with
  the left-most tokens in a URL. This gives a very small
  marginal performance gain as per built-in benchmark.
2019-05-22 17:51:03 -04:00
Raymond Hill
e8c2f7eea3
Fix "Close this window" not working on document-blocked page
Related discussion:
- https://www.reddit.com/r/uBlockOrigin/comments/breeux/
2019-05-21 18:56:59 -04:00
Raymond Hill
6f4ccec836
Import translation work from https://crowdin.com/project/ublock 2019-05-21 15:50:53 -04:00
Raymond Hill
32b04fa262
Re-arrange parsing of type options to be order-independent
Related commit:
- 1888033070

This removes the need to place `all` before any negated
type in the list of options.
2019-05-21 14:04:21 -04:00
Raymond Hill
5eff4a027a
Fix https://github.com/gorhill/uBlock/issues/3541 2019-05-20 18:29:28 -04:00
Raymond Hill
cdfbc1ae02
Import translation work from https://crowdin.com/project/ublock 2019-05-20 14:10:21 -04:00
Raymond Hill
1888033070
Add support for all filter option
Related discussion:
- https://www.reddit.com/r/uBlockOrigin/comments/bqnsoa/

The `all` option is equivalent to specifying all
network-based types + `popup`, `document`,
`inline-font`, `inline-script`.

Example from discussion:

    ||bet365.com^$all

Above will block all network requests, block all popups,
prevent inline fonts/scripts from `bet365.com`. EasyList-
compatible syntax does not allow to accomplish that
semantic when using only `||bet365.com^`.

If using specific negated type options along with `all`,
the order in which the options appear is important. In
such case `all` should always be first, followed by
the negated type option(s).
2019-05-20 13:46:36 -04:00
Raymond Hill
4b85838745
Import translation from https://crowdin.com/project/ublock 2019-05-19 18:42:32 -04:00
Raymond Hill
72d9758faa
Ensure the "Filter lists" pane is in sync with update status
Related issue:
- https://github.com/gorhill/uBlock/issues/2394

Additionally, I added a new advanced setting to control
how long after launch an auto-update session should be
started -- value is in seconds:

    autoUpdateDelayAfterLaunch 180
2019-05-19 18:31:12 -04:00
Raymond Hill
a0ac1b7ee8
Fix handling of data: for filtering purpose in logger
Related issue:
- https://github.com/gorhill/uBlock/issues/2469
2019-05-19 17:00:49 -04:00
Raymond Hill
f677443878
Warn when navigating away from pane with unsaved changes
Related issue:
- https://github.com/gorhill/uBlock/issues/3271

When navigating away by clicking another pane tab button,
there will be an embedded warning, which can be ignore
in order to proceed to the new pane, or dismissed by
either clicking on the "Stay" button or anywhere else
in the dashboard.

When navigating away by trying to close the tab, there will
be a built-in browser warning asking for confirmation.
2019-05-19 15:35:00 -04:00
Raymond Hill
1caff7429e
Add optional support for generic procedural cosmetic filters
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/131

The new advanced setting and its default value is:

    allowGenericProceduralFilters false

Whenever this setting is toggled, the user is responsible
of forcing a reload of all filter lists so as to allow uBO
to process differently any existing generic procedural
cosmetic filters.
2019-05-18 18:57:32 -04:00
Raymond Hill
e66e4496ed
Fix https://github.com/uBlockOrigin/uBlock-issues/issues/360 2019-05-18 17:50:58 -04:00
Raymond Hill
ca34bc4f3e
Fix "Revert" button not resetting after saving changes
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/367
2019-05-18 17:48:19 -04:00
Raymond Hill
3cf71835c4
Set default delay for creating selfie to 3 minutes
Related discussion:
- https://www.reddit.com/r/uBlockOrigin/comments/bq49zi/
2019-05-18 14:43:44 -04:00
Raymond Hill
f7bbc80717
Improve "Whitelist pane"; remove now useless built-in switch rule
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/214

Built-in whitelist directives are now rendered differently
than user-defined whitelist directives. Also, removing a
built-in whitelist directive will only cause that directive
to be commented out, so that users do not have to remember
built-in directives should they want to bring them back.

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

The built-in per-site switch rule
`no-scripting: behind-the-scene false` has been removed,
it should not ever be needed since there will always be a
valid root context for main- and sub-frames.
2019-05-18 14:20:05 -04:00
Raymond Hill
de41c1bf53
Fix parsing of recursive !#if-`!#endif directives
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/270
2019-05-18 10:31:04 -04:00
Raymond Hill
62387fb87a
Prevent picker's preview mode from modifying style attribute
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/551

The issue fixes previewing the hiding/unhiding of targeted
elements in the element picker.

However it does not address the case of previewing
`:style(...)` operators -- this would require a much
more complex fix, which I am not sure is worth the
amount of work and increased code complexity.
2019-05-17 19:26:48 -04:00
Raymond Hill
9cbdff1a9d
Import translation work from https://crowdin.com/project/ublock 2019-05-17 15:02:00 -04:00
Raymond Hill
9bfbbfec84
Adjust visual of cosmetic exception filters in logger
The invariant prefixes `##` and `#@#` are now hidden,
allowing to reveal more of the filter itself when the
logger view is narrow.
2019-05-17 11:45:07 -04:00
Raymond Hill
0ca44b847c
Avoid duplicated strings in filterOrigin w/ new approach
The new approach is simpler and should benefit selfie
serialization/unserialization.

This renders stringDeduplicater obsolete -- it has been
removed.
2019-05-17 10:13:58 -04:00
Raymond Hill
1386429382
Fix regression in applying procedural cosmetic filters
Related commit:
- 3573b6b32c
2019-05-16 17:22:20 -04:00
Raymond Hill
3573b6b32c
Add ability to report exception cosmetic filters in the logger
Related issue:
- https://github.com/gorhill/uBlock/issues/127

Additionally, the extended exception filters in the
logger will be rendered with a line-through to more
easily distinguish them from non-exception ones.

Also, opportunistically converted revisited code to
ES6 syntax.
2019-05-16 13:44:49 -04:00
Raymond Hill
fc109c8b7c
Revisit code to benefit from ES6 syntax 2019-05-15 14:49:12 -04:00
Raymond Hill
1fe3b54acc
Fix cosmetic exception filters not applying
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/575

Regression from:
- 93f80eedfa

Specific cosmetic exception filters need to be returned so that
they can be applied to generic cosmetic filters.
2019-05-15 14:43:59 -04:00
Raymond Hill
39e2a03edb
Fix comment 2019-05-14 09:31:51 -04:00
Raymond Hill
a14dcecf8f
Do not assume wildcards fall on label boundaries
Related commit:
- fe0b7a0e0f

Related feedback:
- https://github.com/uBlockOrigin/uBlock-issues/issues/572#issuecomment-492223980
2019-05-14 09:29:45 -04:00
Raymond Hill
93f80eedfa
Refactor runtime storage of specific cosmetic filters
This was a TODO item:
- 07cbae66a4/src/js/cosmetic-filtering.js (L375)

µBlock.staticExtFilteringEngine.HostnameBasedDB has been
re-factored to accomodate the storing of specific cosmetic
filters.

As a result of this refactoring:

- Memory usage has been further decreased
- Performance of selector retrieval marginally
  improved
- New internal representation opens the door
  to use a specialized version of HNTrie, which
  should further improve performance/memory
  usage
2019-05-14 08:52:34 -04:00
Raymond Hill
8a312b9bbb
Support cases with more than one wildcard
Related commit:
- fe0b7a0e0f

Related feedback:
- https://github.com/uBlockOrigin/uBlock-issues/issues/572#issuecomment-492147440
2019-05-14 06:52:13 -04:00
Raymond Hill
fe0b7a0e0f
Relax destination hostname requirements in redirect filters
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/572

Wildcards are now allowed in the hostname part of redirect
filters. There will be an attempt to find the longest
right-hand portion of the hostname with no wildcard. If
no non-empty hostname can be extracted, `*` will be used.
2019-05-13 20:19:10 -04:00
Raymond Hill
1e40f50eb3
Add benchmark method to cosmetic filtering engine
To measure retrieval of site-specific selectors. From
uBO's own dev console:

    µBlock.cosmeticFilteringEngine.benchmark();
2019-05-12 11:41:47 -04:00
Raymond Hill
57890d60ff
Fix incorrect use of this in static method
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/568

Regression from:
- 19ece97b0c
2019-05-11 17:40:55 -04:00
Raymond Hill
8a7e704080
Add support for nth-ancestor operator in HTML filtering
Also opportunitisically converted some code to
ES6's `class`.
2019-05-11 13:21:23 -04:00
Raymond Hill
915c1f1f3c
Report resources blocked by csp= option in logger
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/552
2019-05-11 10:40:34 -04:00
Raymond Hill
12bdd01595
Ensure "Ignore generic cosmetic filters" sticks on Fennec
Related issue:
- https://www.reddit.com/r/uBlockOrigin/comments/blkudl/

The setting was not sticking at first-install time.
2019-05-11 09:04:13 -04:00
Raymond Hill
ac1a323918
Import translation work from https://crowdin.com/project/ublock 2019-05-10 17:26:34 -04:00
Raymond Hill
e59bdb1485
Defuse fixed position on body element in element zapper
The `fixed` style property on the `body` element will be
defused if an overlay element is removed using the element
zapper.

Related:
- https://www.reddit.com/r/uBlockOrigin/comments/bktxtb/scrolling_doesnt_work/emlscyz
2019-05-06 13:32:55 -04:00
Raymond Hill
26237d6d40
Import translation work from https://crowdin.com/project/ublock 2019-05-06 11:39:41 -04:00
Raymond Hill
3692bb4ada
Add HNTrieRef.dump() and STrieRef.dump() as dev tool
To be used at the console, as an investigation tool for
development purpose.

Using it to verify the content of the largest
FilterHostnameDict instance, I spotted an all-uppercase
hostname in the HNTrieRef instance:

µBlock.staticNetFilteringEngine.categories.get(0).get(0x10000000).dict.dump();

Thus the changes to static-net-filtering.js are to fix
the erroneous insertion of filters with uppercase
characters. The single instance found was a hostname entry
in Malware Domain List (TRIANGLESERVICESLTD dot COM).
2019-05-06 11:12:39 -04:00
Raymond Hill
ce488d9fc8
Import translation work from https://crowdin.com/project/ublock 2019-05-01 20:05:16 -04:00
Raymond Hill
0e4fbefd07
Remove unecessary null placeholders FilterOriginHitSet et al.
The `null` placeholder are not necessary, we can just use
default arguments instead, and add the HNTrieContainer
references if and only if they are instanciated.
2019-05-01 18:54:11 -04:00
Raymond Hill
9e4385243c
Web accessible secrets can be used for at most one second
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/550

Related Chromium issue (I can't access it):
- https://bugs.chromium.org/p/chromium/issues/detail?id=957866

Findings so far: affects browsers based on Chromium 74.
I could not reproduce the issue with either Chromium 73 or
Google Chrome 75.

This commit is a mitigation: to prevent sites from using
uBO's internal WAR secret for tracking purpose. A secret
can be used for at most one second, after which a new secret
is generated.

The original issue related to the implementation of
secret-gated web accessible resources is:
- https://github.com/gorhill/uBlock/issues/2823
2019-04-30 14:36:07 -04:00
Raymond Hill
73e2f25e95
Add new cosmetic procedural operator: :nth-ancestor(n)
The purpose of this new `:nth-ancestor(n)` operator is to
lookup the nth ancestor relative to the currently selected
node.

It is essentially equivalent to `:xpath(..)`, where
ancestor distance is expressed as a number rather than a
sequence of slash-separated `..`.

The rationale to introduce this new procedural selector
is to have a low overhead way to accomplish ancestor
selection.
2019-04-30 09:02:14 -04:00
Raymond Hill
42bf659695
Revert "Order HNTrie nodes alphabetically to allow for early bailout"
This reverts commit f5f9e05071.
2019-04-30 07:00:52 -04:00
Raymond Hill
f5f9e05071
Order HNTrie nodes alphabetically to allow for early bailout
This commit implements the alphabetical ordering of HNTrie
nodes, so as to make it possible to bail out early at
HNTrie.matches() time.

Contrary to what I expected, there is no performance gain
observed to HNTrie.matches() as per benchmarks -- I find
the results perplexing.

Because of this I will revert this commit immediately.
The purpose of this commit is to record the changes so
that I can bring them back to life in the future whenever
I want to investigate further.
2019-04-30 06:47:54 -04:00
Raymond Hill
adabb56dc9
Do not store impossible to match filters in HNTrie
Consider the two following filters:

    example.com
    www.example.com

This commit make it so that if the first filter is
already present in a given HNTrie, the second filter
will not be stored, since HNTrie will _always_
return the first filter as a match whenever the
hostname to match is example.com or any subdomain
of example.com.

The detection of such pointless filters is
virtually free when adding a hostname to an HNTrie
instance (given how data is stored in the trie), so
in practice no overhead is incurred to detect such
pointless filters.

The ability to ignore impossible to match filters
in HNTrie instances will _especially_ benefit those
using large hosts files.

Examples of how this helps using real configurations:

- Default lists:
  444 filters out of 100,382 were ignored as a result
  of this commit.

- Default lists + "Energized Ultimate Protection":
  283,669 filters out of 903,235 were ignored as a
  result of this commit.

Side note: There was no measurable difference between
the two configurations above in the performance of
the matching algorithm as reported by the built-in
benchmark tool.
2019-04-29 13:15:16 -04:00
Raymond Hill
c4f9ae706a
Fix alternate code path introduced in 295f08da97 (oops) 2019-04-28 14:18:09 -04:00
Raymond Hill
295f08da97
Implement code path for when TextDecoder() is not available
The primary purpose is to unbreak
https://github.com/cliqz-oss/adblocker/tree/master/bench/comparison
2019-04-28 14:07:21 -04:00
Raymond Hill
ac58b8e688
Make token hashes fit within a 32-bit integer
The staticNetFilteringEngine uses token hashes to store/lookup
filters into Map objects.

Before this commit, the tokens were encoded into token hashes
as JS numbers (not exceeding MAX_SAFE_INTEGER) using at most
the 8 first characters of the token.

With this commit, token hashes are now restricted to fit
into 32-bit integers, and are derived from at most the 7 first
characters. This improves filter look-up performance as per
built-in benchmark().
2019-04-28 10:15:15 -04:00
Raymond Hill
510cda0bc5
Support in logger's filter expression picker 2019-04-28 07:23:14 -04:00
Raymond Hill
96dce22218
Increase resolution of known-token lookup table
Related commit:
- 69a43e07c4

Using 32 bits of token hash rather than just the 16 lower
bits does help discard more unknown tokens.

Using the default filter lists, the known-token lookup
table is populated by 12,276 entries, out of 65,536, thus
making the case that theoretically there is a lot of
possible tokens which can be discarded.

In practice, running the built-in
staticNetFilteringEngine.benchmark() with default filter
lists, I find that 1,518,929 tokens were skipped out of
4,441,891 extracted tokens, or 34%.
2019-04-27 08:18:01 -04:00
Raymond Hill
a8946c8d73
Fix list lookup of multi-hostname domain= filters in logger
Related commit:
- 3f3a1543ea

The regression was preventing uBO to find from which list a filter
originated. This affected only filters for which the `domain=`
option had multiple hostnames.
2019-04-27 07:04:43 -04:00
Raymond Hill
4c9e760a10
Import translation work from https://crowdin.com/project/ublock 2019-04-26 17:30:19 -04:00
Raymond Hill
69a43e07c4
Ignore unknown tokens in urlTokenizer.getTokens()
Given that all tokens extracted from one single URL are potentially
iterated multiple times in a single URL-matching cycle, it pays to
ignore extracted tokens which are known to not be used anywhere in
the static filtering engine.

The gain in processing a single network request in the static
filtering engine can become especially high when dealing with
long and random-looking URLs, which URLs have a high likelihood
of containing a majority of tokens which are known to not be in
use.
2019-04-26 17:14:00 -04:00
Raymond Hill
19ece97b0c
Leverage compile-time token information in new fitler classes
Related commit:
- 99390390fc

The token information available at compile time can be stored
in the filter to be used at match() time. This allows the use of
startsWith() rather than a more costly indexOf() call as a first
quick test to detect mismatches.
2019-04-26 11:16:47 -04:00
Raymond Hill
f667fc2d65
Fix page count computation in publicSuffixList.enableWASM() 2019-04-25 19:40:07 -04:00
Raymond Hill
e0d2285da0
Convert HNTrie code to ES6 class 2019-04-25 19:38:07 -04:00
Raymond Hill
155abfba18
Cache and reuse result of HNTrieRef.matches() when possible
Due to how web pages typically load secondary resources and due
to how HNTrieContainer instances are used in uBO, there is a
great likelihood that the result of a previous call to
HNTrieRef.matches() can be reused in a subsequent call.
This has been confirmed by instrumenting HNTrieRef.matches().

Since uBO uses distinct HNTrieContainer instances to either
match against the request or the origin hostnames, this
means a high likelihood of repeated calls to HNTrieRef.matches()
with the same hostname as argument, hence a performance gain
when caching the argument+result -- as despite that
HNTrie.matches() is fast, comparing two short strings is even
faster if this allows to skip HNTrie.matches() altogether.
2019-04-25 18:36:03 -04:00
Raymond Hill
99390390fc
Introduce three more specialized filter classes to avoid regexes
Performance- and memory-related work. Three more classes have
been created to avoid regex-based filters internally.

Purpose is to enforce filters which have only one single
wildcard in their pattern, a common occurrence. The filter
pattern is split in two literal string segments.

Similar as above, with the added condition that the filter is
hostname-anchored (`||`). The "Wildcard2" variant is a further
specialization to enforce filters where the only wildcard
is immediately preceded by the `^` special character, again
a very common occurrence.

Using two literal string segments in lieu of regexes allows to
quickly detect a mismatch by just testing the first segment.
Additionally, this reduces memory footprint as regexes are
much more expensive memory-wise than plain strings.

These three new filter classes allow to replace the use of
5276 regex-based filters internally with plain string-based
filters.

Often-called isHnAnchored() has been further fine-tuned to
avoid as much work as possible. I have also observed that
using an arrow function for closure-purpose helps measurably
performance, as per built-in benchmark.
2019-04-25 17:48:08 -04:00
Raymond Hill
fff2bb6290
Assume media elements with no Content-Length header to be of size 0
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/543
2019-04-24 08:30:54 -04:00
Raymond Hill
72bbcdd93c
Prevent search expression in CodeMirror editor from crossing line boundaries
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/493
2019-04-23 19:26:02 -04:00
Raymond Hill
cd1a11fa9d
Update to CodeMirror version 5.46 2019-04-23 19:06:03 -04:00
Raymond Hill
c535c624bd
Import translation work from https://crowdin.com/project/ublock 2019-04-23 09:32:15 -04:00
Raymond Hill
3c5102811a
Fix the logger's rendering of hostnames starting with digits
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/541
2019-04-23 09:28:00 -04:00
Raymond Hill
16a76aa524
Add filter expressions in logger's expression picker
- Added `media`
- Include `generichide` in `dom` filter expression
- Include `beacon`/`csp_report`/`ping` in `other filter expression
2019-04-22 10:23:58 -04:00
Raymond Hill
43ecffc295
Fix overzealous strict blocking (regression)
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/536

Regression from:
- 3f3a1543ea (diff-522a16ddeed280252d7c3a351261b441R2767)
2019-04-21 09:17:31 -04:00
Raymond Hill
f10b100379
Fix the handling of pseudoclass-based generic cosmetic filters
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/464

Regression from:
261ef8c510 (diff-3b15596213ed9ba37fb5b8bb1402a6c2R599)

Pseudoclass-based generic cosmetic filters were improperly seen
as invalid following the regression.
2019-04-21 07:49:44 -04:00
Raymond Hill
7735b35e21
Fix uncaught rejected promise in assets.fetchText()
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/534

Regression from
a52b07ff6e
2019-04-21 06:12:20 -04:00
Raymond Hill
97f91f8be9
Small code review of a52b07ff6e 2019-04-20 19:10:34 -04:00