1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-07-08 04:49:12 +02:00
Commit Graph

2643 Commits

Author SHA1 Message Date
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