Commit graph

166 commits

Author SHA1 Message Date
Raymond Hill
fc109c8b7c
Revisit code to benefit from ES6 syntax 2019-05-15 14:49:12 -04:00
Raymond Hill
a52b07ff6e
Make userResourcesLocation able to support multiple URLs
The URLs must be space-separated.

Reminders:
- The additional resources will be updated at the same time
  the built-in resource file is updated
- Purging the cache of 'uBlock filters' will also purge the
  cache of the built-in resource file -- and hence force a
  reload of the user's custom resources if any

Related issues:
- https://github.com/gorhill/uBlock/issues/3307
- https://github.com/uBlockOrigin/uAssets/issues/5184#issuecomment-475875189

Addtionally:
- Opportunitically promisified assets.fetchText()
- Fixed https://github.com/gorhill/uBlock/issues/3586
2019-04-20 17:16:49 -04:00
Raymond Hill
fa83744b58
Use a sequence of base 64 numbers to encode array buffers
The purpose of using a custom base128 encoder is to
convert array buffers into strings, to allow a direct
string-to-array buffer conversion at load time:

  string => array buffer

Whereas a JSON array would require an extra step:

  JSON array as string => JS array => array buffer

Turns out that the current use of a custom base128 encoding
results in a significantly larger selfie storage usage when
converting array buffers into strings.

Speculation: possibly the browser convert the strings to
save into JSON strings internally. Since the custom base128
encoder is likely to cause the resulting string to contain
a lot of unprintable ASCII characters, these will need to
be escaped when converted to JSON -- escaped characters
occupy more space than non-escaped ones.

Using a sequence of base 64 numbers means only printable
will be present in the output string, hence no escaping
necessary. I have observed significant reduction in
storage usage for selfie purpose.
2019-04-20 09:06:54 -04:00
Raymond Hill
c9c21f9cbf
Add more languages for list selection at install/reset time
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/501

Also, the handling of 3-letter language codes has been fixed.
2019-04-14 18:20:57 -04:00
Raymond Hill
2fd587b7ae
Simplyfy code to gather storage used with StorageManager.estimate()
Documentation:
https://developer.mozilla.org/docs/Web/API/StorageManager
2019-03-22 22:09:27 -03:00
Raymond Hill
008370e4b9
Fix https://github.com/uBlockOrigin/uBlock-issues/issues/461
uBO will fallback using a JSON string when trying to encode an array
buffer in Chromium version 59 and earlier.
2019-03-16 09:00:31 -04:00
Raymond Hill
87feb47b51
Support disabling suspendTabsUntilReady in Firefox
The value of `suspendTabsUntilReady` was disregarded in Firefox and
uBO defaulted to always defer tab loading until it was ready.

This commit allows to disable the deferring of tab loading in
Firefox. The new valid values for `suspendTabsUntilReady` are:
- `unset`: leave it to the platform to pick the optimal
  behavior (default)
- `no`: do no suspend tab loading at launch time
- `yes`: suspend tab loading at launch time
2019-02-19 12:30:37 -05:00
Raymond Hill
426a6ea9a7
Fix spurious output at uBO's dev console
Regression from https://github.com/gorhill/uBlock/commit/0d369cda21bb
2019-02-18 14:41:04 -05:00
Raymond Hill
f7a632c94a
Fix regression preventing new install or reseting to factory default
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/431
2019-02-18 06:18:30 -05:00
Raymond Hill
0d369cda21
Allow use of browser.storage.local as cache storage backend in Firefox
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/409

By default `indexedDB` is used in Firefox for purpose of cache storage
backend.

This commit allows to force the use of `browser.storage.local` instead
as cache storage backend. For this to happen, set `cacheStorageAPI` to
`browser.storage.local` in advanced settings.

Additionally, should `indexedDB` not be available for whatever reason,
uBO will automatically fallback to `browser.storage.local`.
2019-02-17 15:40:09 -05:00
Raymond Hill
ed7e34fb07
Refactor selfie generation into a more flexible persistence mechanism
The motivation is to address the higher peak memory usage at launch
time with 3rd-gen HNTrie when a selfie was present.

The selfie generation prior to this change was to collect all
filtering data into a single data structure, and then to serialize
that whole structure at once into storage (using JSON.stringify).

However, HNTrie serialization requires that a large UintArray32 be
converted into a plain JS array, which itslef would be indirectly
converted into a JSON string. This was the main reason why peak
memory usage would be higher at launch from selfie, since the JSON
string would need to be wholly unserialized into JS objects, which
themselves would need to be converted into more specialized data
structures (like that Uint32Array one).

The solution to lower peak memory usage at launch is to refactor
selfie generation to allow a more piecemeal approach: each filtering
component is given the ability to serialize itself rather than to be
forced to be embedded in the master selfie. With this approach, the
HNTrie buffer can now serialize to its own storage by converting the
buffer data directly into a string which can be directly sent to
storage. This avoiding expensive intermediate steps such as
converting into a JS array and then to a JSON string.

As part of the refactoring, there was also opportunistic code
upgrade to ES6 and Promise (eventually all of uBO's code will be
proper ES6).

Additionally, the polyfill to bring getBytesInUse() to Firefox has
been revisited to replace the rather expensive previous
implementation with an implementation with virtually no overhead.
2019-02-14 13:33:55 -05:00
Raymond Hill
4da340384a
Update publicSuffixLibrary to latest (WASM-able) version
See https://github.com/gorhill/publicsuffixlist.js
2019-02-10 12:19:05 -05:00
Raymond Hill
a026e9ae54
Fix reverting use of IndexedDB as default cache storage on Chromium
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/399

The advanced setting `cacheStorageAPI` has been added to allow
a user to force the use of IndexedDB as cache storage. Set to
`IndexedDB` to force use of IndexedDB. Default to `unset`.
2019-01-25 18:49:30 -05:00
Raymond Hill
64bea27881
Add ability to control auto-commenting at filter creation time
Related issues:
- https://github.com/uBlockOrigin/uBlock-issues/issues/372
- https://github.com/gorhill/uBlock/issues/93

A new advanced settings has been added: `autoCommentFilterTemplate`.

Default value is `{{date}} {{origin}}`.

Placeholders are identified by `{{...}}`. There are currently
only three placeholders supported:

- `{{date}}`: will be replaced with current date
- `{{time}}`: will be replaced with current time
- `{{origin}}`: will be replaced with site information on which
  the filter(s) was created

If no placeholder is found in `autoCommentFilterTemplate`, this
will disable auto-commenting. So one can use `-` to disable
auto-commenting.

Additionally, if auto-commenting is enabled, uBO will not emit a
comment if an emitted comment would be a duplicate of the last
one found in the user filter list.
2019-01-08 07:37:50 -05:00
Raymond Hill
261ef8c510
Add support for procedural :not to HTML filtering
Related issue: <https://github.com/gorhill/uBlock/issues/3683>

Additionally, improve compile-time error reporting in the logger
2018-12-15 10:46:17 -05:00
Raymond Hill
e7d4aff2a2
fix https://github.com/uBlockOrigin/uBlock-issues/issues/328 2018-12-05 19:18:20 -05:00
Raymond Hill
2189f020df
add new advanced setting to disable use of WASM for dev purpose 2018-11-16 10:19:06 -05:00
Raymond Hill
d7d544cda0
Squashed commit of the following:
commit 7c6cacc59b27660fabacb55d668ef099b222a9e6
Author: Raymond Hill <rhill@raymondhill.net>
Date:   Sat Nov 3 08:52:51 2018 -0300

    code review: finalize support for wasm-based hntrie

commit 8596ed80e3bdac2c36e3c860b51e7189f6bc8487
Merge: cbe1f2e 000eb82
Author: Raymond Hill <rhill@raymondhill.net>
Date:   Sat Nov 3 08:41:40 2018 -0300

    Merge branch 'master' of github.com:gorhill/uBlock into trie-wasm

commit cbe1f2e2f38484d42af3204ec7f1b5decd30f99e
Merge: 270fc7f dbb7e80
Author: Raymond Hill <rhill@raymondhill.net>
Date:   Fri Nov 2 17:43:20 2018 -0300

    Merge branch 'master' of github.com:gorhill/uBlock into trie-wasm

commit 270fc7f9b3b73d79e6355522c1a42ce782fe7e5c
Merge: d2a89cf d693d4f
Author: Raymond Hill <rhill@raymondhill.net>
Date:   Fri Nov 2 16:21:08 2018 -0300

    Merge branch 'master' of github.com:gorhill/uBlock into trie-wasm

commit d2a89cf28f0816ffd4617c2c7b4ccfcdcc30e1b4
Merge: d7afc78 649f82f
Author: Raymond Hill <rhill@raymondhill.net>
Date:   Fri Nov 2 14:54:58 2018 -0300

    Merge branch 'master' of github.com:gorhill/uBlock into trie-wasm

commit d7afc78b5f5675d7d34c5a1d0ec3099a77caef49
Author: Raymond Hill <rhill@raymondhill.net>
Date:   Fri Nov 2 13:56:11 2018 -0300

    finalize wasm-based hntrie implementation

commit e7b9e043cf36ad055791713e34eb0322dec84627
Author: Raymond Hill <rhill@raymondhill.net>
Date:   Fri Nov 2 08:14:02 2018 -0300

    add first-pass implementation of wasm version of hntrie

commit 1015cb34624f3ef73ace58b58fe4e03dfc59897f
Author: Raymond Hill <rhill@raymondhill.net>
Date:   Wed Oct 31 17:16:47 2018 -0300

    back up draft work toward experimenting with wasm hntries
2018-11-03 08:58:46 -03:00
Raymond Hill
c0fc7dd869
fix https://github.com/uBlockOrigin/uBlock-issues/issues/248 2018-10-24 20:02:15 -03:00
Raymond Hill
cabb0d36b6
fix https://github.com/gorhill/uBlock/issues/3371 2018-10-23 14:01:08 -03:00
Raymond Hill
6d34a52179
fix #2859 2018-09-03 14:06:49 -04:00
Raymond Hill
8ca6239e64
fix https://github.com/NanoAdblocker/NanoCore/issues/202 2018-08-30 08:32:56 -04:00
Raymond Hill
38aabc937a
reorganize cache storage compression; workaround fix for #2812 2018-08-11 10:39:43 -04:00
Raymond Hill
e163080518
added optional lz4 compression for cache storage (https://github.com/uBlockOrigin/uBlock-issues/issues/141)
Squashed commit of the following:

commit 6a8473822537636ac54d5dabdb14472114bb730b
Author: Raymond Hill <rhill@raymondhill.net>
Date:   Mon Aug 6 10:56:44 2018 -0400

    remove remnant of snappyjs and spurious instruction

commit 9a4b709bee97d3cc2235fab602359fa5953bdb46
Author: Raymond Hill <rhill@raymondhill.net>
Date:   Mon Aug 6 09:48:58 2018 -0400

    make cache storage compression optionally available on all platforms

    New advanced setting: `cacheStorageCompression`. Default is `false`.

commit 22ee6547f2f7c9c5aefe25dea1262a1b31612155
Author: Raymond Hill <rhill@raymondhill.net>
Date:   Sun Aug 5 19:16:26 2018 -0400

    remove Chromium from lz4 experiment

commit ee3e201c45afe983508f70713a2d43af74737d8d
Author: Raymond Hill <rhill@raymondhill.net>
Date:   Sun Aug 5 18:52:43 2018 -0400

    import lz4-block-codec.wasm library

commit 883a3118efcfd749c82356fde7134754d6ae371d
Author: Raymond Hill <rhill@raymondhill.net>
Date:   Sun Aug 5 18:50:46 2018 -0400

    implement storage compression through lz4-wasm [draft]

commit 48d1ccaba407de447c2cd6747dc3a90839c260a7
Merge: 8ae77e6 b34c897
Author: Raymond Hill <rhill@raymondhill.net>
Date:   Sat Aug 4 08:56:51 2018 -0400

    Merge branch 'master' of github.com:gorhill/uBlock into lz4

commit 8ae77e6aeeaa85af335e664c2560d2afd37288c6
Author: Raymond Hill <rhill@raymondhill.net>
Date:   Wed Jul 25 18:17:45 2018 -0400

    experiment with compression
2018-08-06 12:34:41 -04:00
Raymond Hill
7702b1f4bc
minor code review 2018-07-25 18:24:14 -04:00
Raymond Hill
7ae68c8d7d
fix https://github.com/uBlockOrigin/uBlock-issues/issues/144 2018-07-24 09:17:18 -04:00
Raymond Hill
798f8dab9d
reduce baseline memory at selfie-load time 2018-06-01 07:54:31 -04:00
Hugo Xu
de6cf0e6aa Align header parsing to ABP (#3724) 2018-05-16 14:55:12 -04:00
Hugo Xu
25786c3257 Round hour up to nearest day (#3723)
* Update storage.js

* Update storage.js
2018-05-16 11:01:40 -04:00
Raymond Hill
f64d703ba0
fix quirks in parsing of Steven Black's hosts files 2018-05-01 18:29:58 -04:00
Raymond Hill
3923520b87
remove no longer needed platform-dependent polyfill.js 2018-04-27 08:36:38 -04:00
Hugo Xu
ae6b376a75 Fix RegExp escape (#3700) 2018-04-11 11:28:10 -04:00
Raymond Hill
c34326cf4e
code review: further tuning filter list directives 2018-04-11 06:34:13 -04:00
Raymond Hill
00cb02ec47
fix new hidden setting default value not being applied (https://github.com/orgs/uBlockOrigin/teams/volunteers/discussions/62) 2018-04-09 17:46:29 -04:00
Raymond Hill
47598d4499
further fine tune "Filter lists" pane (b60c06f3) 2018-04-09 15:45:25 -04:00
Raymond Hill
26c2320e46
code review: improve compatibility with StevenBlack hosts files 2018-04-09 15:40:29 -04:00
Raymond Hill
daf948b779
fix https://github.com/gorhill/uBlock/pull/3679#issuecomment-379092981 2018-04-06 16:15:10 -04:00
Raymond Hill
a015ad0a5c
Merge branch 'master' of github.com:gorhill/uBlock 2018-04-06 16:02:41 -04:00
Raymond Hill
4d8974fe80
code review: avoid redundant PSL selfie 2018-04-06 16:02:35 -04:00
Hugo Xu
fc4fccd8e3 Accept # Title: and # Expires:; optimize RegExp (#3679)
* Accept `# Title:` and `# Expires`; optimize RegExp

* Prevent confusion with network filter
2018-04-06 15:59:01 -04:00
Raymond Hill
c0387835fa
code review: modernize old code 2018-04-05 15:22:19 -04:00
Raymond Hill
93f49a61d7
add pre-processor directives to filter list compiler (https://github.com/AdguardTeam/AdguardBrowserExtension/issues/917) 2018-04-05 07:29:15 -04:00
Raymond Hill
9fb455d2df
fix #3406 2018-02-23 06:42:17 -05:00
Raymond Hill
a81d2a759b
fix #3318, #3387 2018-02-21 13:29:36 -05:00
Raymond Hill
17930cc778
fix #3474, #2823 2018-02-15 17:25:38 -05:00
Raymond Hill
636dcf7ee4
fix #3383 2018-01-01 07:52:03 -05: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
Raymond Hill
36956cbc7a
remove obsolete resource caching code 2017-12-14 16:42:54 -05:00
gorhill
118240d36d
fix #3232 (regression from 386e8bee9c) 2017-11-15 16:32:52 -05:00