Commit graph

31 commits

Author SHA1 Message Date
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
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
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
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
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
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
b54522caa1
[scriptlet engine] Mind old scriptlet names not using .js
Related commit:
- 5552d6717d
2019-07-09 11:36:42 -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
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
0ba9a35818
Convert more resources as immutable
Related commit:
- 152cea2dfe
2019-07-03 14:33:06 -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
c83b6776da
Remove support for implicit scriptlet injection
Related issue:
- https://github.com/gorhill/uBlock/issues/3550
2019-02-20 07:18:37 -05:00
Raymond Hill
9b27a98f90
Fix https://github.com/gorhill/uBlock/issues/3654
Additionally, there has been refactoring work done regarding
filtering context used throughout uBO, motivated by the fix
here.
2018-12-13 12:30:54 -05:00
Raymond Hill
5d98a88093
revert unintended stray change from commit 4504040344 2018-11-24 12:21:25 -05:00
Raymond Hill
4504040344
minor code review: do not cache hostname/domain pairs when parsing filters 2018-11-24 12:09:27 -05:00
Raymond Hill
06fe7e6871
code review for static extended filtering, notably:
- use domain-derived integer hash to store filters

- remove code meant for firefox/legacy

- properly handle subdomains of entity-based filters
2018-09-09 08:10:09 -04:00
Raymond Hill
89c073f3e9
fix https://github.com/uBlockOrigin/uBlock-issues/issues/209 2018-09-07 09:11:07 -04:00
Raymond Hill
79d5af20fc
fix potential spurious error from ignoring chrome.runtime.lastError 2018-07-08 08:25:08 -04:00
Raymond Hill
4a57825411
code review: remove scriplet js text after injection (see https://github.com/uBlockOrigin/uBlock-issues/issues/53#issuecomment-394024828) 2018-06-01 18:41:27 -04:00
Raymond Hill
f887eeb3f5
code review for c5d8588118: mind whitelist status; mind an inaccessible document 2018-05-22 09:26:49 -04:00
Raymond Hill
0c5e2eb7ee
code review for c5d8588118: mind about:blank et al. iframes 2018-05-20 06:49:12 -04:00
Raymond Hill
b4306e3297
code reivew of c5d8588118: immediate scriptlets injection works well only on Chromium-based browsers for now 2018-05-18 10:19:14 -04:00
Raymond Hill
e693e308d4
code review for c5d8588118 2018-05-17 16:24:08 -04:00
Raymond Hill
c5d8588118
inject scriptlets earlier (experimental) (ex. https://github.com/uBlockOrigin/uAssets/issues/2300) 2018-05-17 07:33:21 -04:00
Hugo Xu
60751044fe Update scriptlet-filtering.js (#3696) 2018-04-09 17:49:35 -04:00
Raymond Hill
5c20182948
fix regression in per-list filter counts (reported by @mapx-) 2017-12-29 13:31:37 -05:00
Raymond Hill
a9f68fe02f
Fix #3069, and consequently #3374, #3378.
A new filtering class has been created: "static extended filtering".
This new class is an umbrella class for more specialized filtering
engines:
- Cosmetic filtering
- Scriptlet filtering
- HTML filtering

HTML filtering is available only on platforms which support modifying
the response body on the fly, so only Firefox 57+ at the moment.

With the ability to modify the response body, HTML filtering has
been introduced: removing elements from the DOM before the source
data has been parsed by the browser.

A consequence of HTML filtering ability is to bring back script tag
filtering feature.
2017-12-28 13:49:02 -05:00