Commit Graph

726 Commits

Author SHA1 Message Date
Raymond Hill 184e4f7a42
Avoid reloading the dashboard tab if it is already present
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/592
2019-05-24 20:15:40 -04:00
Raymond Hill eed13194fb
Handle possible exceptions in vAPI.messaging.broadcast()
I had exceptions thrown by that code once in a while,
about the `port` object not being connected; possibly
occurs only when using dev tools with breakpoints
in uBO's code. Even if this can be reproduced randomly
only when debugging uBO, it costs nothing to add code
in there to handle exceptions.
2019-05-21 14:07:38 -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 b87b242384
Use per-request secret rather than time-based secret
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/550
2019-05-01 07:41:04 -04:00
Raymond Hill 99212e3264
Code review: use function arrow properly 2019-05-01 06:35:47 -04:00
Raymond Hill 016625465e
Simplify a bit 9e43852 by using Array.every() 2019-04-30 16:18:40 -04:00
Raymond Hill 0714aceaaf
Simplify secret generation introduced in 9e4385243c 2019-04-30 15:19:10 -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 367cdd6666
Make use of `X-DNS-Prefetch-Control` in Chromium-based browsers
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/548

The fix applies only to Chromium-based browsers -- a
`X-DNS-Prefetch-Control` header[1] will be unconditionally
injected when uBO's "Disable pre-fetching" setting is
enabled (it is by default).

This is a mitigation, this does not completely fix the issue
of the setting "Disable pre-fetching" being disregarded on
Chromium-based browsers when sites use
`preconnect`/`preload`.

[1] https://developer.mozilla.org/docs/Web/HTTP/Headers/X-DNS-Prefetch-Control
2019-04-27 13:12:33 -04:00
Raymond Hill 977178bef2
Use a lower WebRTC mode on Firefox to hide private IP addresses
Releated issue:
- https://github.com/gorhill/uBlock/issues/3009

Firefox implements differently the behavior of `disable_non_proxied_udp`,
and this probably leads to more oft-misdiagnosed breakage.

Example:
https://www.reddit.com/r/firefox/comments/b4guyl/gotowebmeeting_same_unsupported_bs/
2019-03-23 16:23:42 -03: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 83a3767a16
Test presence of `firefox` instead of absence of `chromium` 2019-02-12 15:29:20 -05:00
Raymond Hill 8c4249a870
Try to not rely on UA to lookup environment flavor
The environment flavor is used to by uBO to for self-configuration.

For users with spoofed UA at the `about:config` level, this might
cause uBO to misconfigure itself. Avoid UA and strictly rely on
browserInfo() for looking up environment parameters.
2019-02-12 11:11:58 -05:00
Raymond Hill 656203adc7
Minor generic code review of changes since 1.18.2 2019-02-02 08:09:34 -05:00
Raymond Hill 920eee88be
Code review: ensure vAPI.shutdown.exec is called from root context only
This prevents uncaught errors in content scripts when uBO's main
process is terminated (i.e. disabled, updated).
2019-01-28 16:16:52 -05:00
Raymond Hill a6ebcc85be
Reuse both flavors of webRequest wrapper in webext package
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/407

Both flavors will be stitched together into a single
`vapi-qebrequest.js` file.

The decision of which flavor to use will be made at runtime,
according to the browser environment.
2019-01-28 16:12:26 -05:00
Raymond Hill 15100459b3
Harden content script's message Port against spurious disconnections
Those spurious disconnections have been observed to occur at
uBO's launch time.

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

I have observed that this fixes an issue observed on Firefox 64
(current stable).

The reported Waterfox issue *may* be fixed as a result. If not,
the issue he still considered fixed as Waterfox is not
officially supported.
2019-01-27 17:07:40 -05:00
Raymond Hill 41548be6be
Move early blocking of requests out of experimental status on Firefox
Related issues:
- https://github.com/gorhill/uBlock/issues/2067
- https://github.com/uBlockOrigin/uBlock-issues/issues/128

Related mozbug issue:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1503721
2018-12-23 17:59:31 -05:00
Raymond Hill 5b7a3c9983
fix https://github.com/uBlockOrigin/uBlock-issues/issues/256; add regex support in logger filter field 2018-12-14 11:01:21 -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 5c33a57158
fix reported extension error in Chrome 72.0.3622.0
Apparently the "file:///" permission is redundant to the declared
"<all_urls>" permission.
2018-12-05 14:46:35 -05:00
Raymond Hill ec55191a25
fix regression reported at https://www.reddit.com/r/uBlockOrigin/comments/9vcrk3/bug_in_ubo_1173_betas_when_saving_files_hosted_on/ 2018-11-08 19:58:45 -02:00
Raymond Hill 649f82f901
fix https://github.com/uBlockOrigin/uBlock-issues/issues/296 2018-11-02 08:55:15 -03:00
Raymond Hill 9039874fc9
refactor some webRequest-related code (now that firefox legacy is out of the way) 2018-10-28 10:58:25 -03:00
Raymond Hill fee65bec57
fix another case of https://github.com/uBlockOrigin/uBlock-issues/issues/167 2018-09-29 18:56:59 -04:00
Raymond Hill 6dd6dc5f1d
fix https://www.reddit.com/r/uBlockOrigin/comments/9gwrna/when_you_right_click_and_go_to_options_it_keeps/ 2018-09-18 20:14:09 -04:00
Raymond Hill 3ef4005f63
remove obstacle to modernize codebase with ES6 syntax: bump up min version for Chromium 2018-09-03 14:03:38 -04:00
Raymond Hill c00297680b
fix https://www.reddit.com/r/uMatrix/comments/8lc9ia/ 2018-08-25 12:57:21 -04:00
Raymond Hill 273f1db297
fix <https://github.com/uBlockOrigin/uBlock-issues/issues/168>: Firefox for Android does not support the windows API 2018-08-14 18:56:08 -04:00
Raymond Hill dc430f1eff
fix https://github.com/uBlockOrigin/uBlock-issues/issues/167 2018-08-14 14: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 3bcdddfb9f
fix missing exception handler (https://github.com/uBlockOrigin/uBlock-issues/issues/141) 2018-07-23 13:13:47 -04:00
Raymond Hill 06756baed9
improve use of imageData in setIcon
- Generate imageData according to existing path information
- Pass a copy as argument (see 06768dcadb)
2018-05-27 11:13:25 -04:00
Raymond Hill 3b61ef51b0
fix version parsing in 91b0ac5b3f 2018-05-20 08:12:09 -04:00
Raymond Hill 91b0ac5b3f
fix dd92337a4a (commitcomment-29051501) 2018-05-20 07:45:39 -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
Raymond Hill 0458d01eb2
handle initiator === "null" (see https://issues.adblockplus.org/ticket/6586) 2018-05-14 08:11:50 -04:00
Raymond Hill a9a1cc3f3b
code review: use setIcon w/ ImageData only for chromium-based browsers 2018-05-09 08:08:19 -04:00
Raymond Hill d3691cf45a
fix https://github.com/uBlockOrigin/uBlock-issues/issues/32 2018-05-08 15:01:25 -04:00
Raymond Hill 7e5661383a
code review to further lower overhead of updating toolbar icon 2018-05-08 09:43:25 -04:00
Raymond Hill 89fd76ac39
use image data instead of paths for browser icons
When using paths, platform implementations of setIcon typically
will fetch the resource then convert to image data internally.
It is preferable for uBO to do this conversion itself as it can
be done only once at launch time.

With chromium-based browsers, using image data eliminate the
incessant network traffic to fetch browser icons as reported
in the extension's dev tool, meaning a good chunk of overhead
is eliminated.

Also, use optimal icon sizes, as of now both chromium and firefox
prefers 16px instead of 19px, and 32px instead of 38px.
2018-05-07 19:03:50 -04:00
Raymond Hill 14709d18cf
fix #2809 2018-05-04 08:44:54 -04:00
Raymond Hill 8be1aed04d
guard against future instances of issue fixed in #3721 2018-05-03 09:55:36 -04:00
Rob Wu b27f23d520 Clear return value of vapi.js content script (#3721)
Upon start-up, uBlock runs all content scripts in manifest.json using
`chrome.tabs.executeScript`. When this API is used, the value of the
last expression is automatically cloned and transferred to the
callback of `chrome.tabs.executeScript`. This is convenient if needed,
and a performance burden otherwise (the latter is the case for uBlock).

There are three content scripts that need to be checked:

- vapi.js
  The last expression is often the vAPI object, and it is relatively
  expensive to clone this object. This commit sets the value of the
  last expression to `void 0` to solve this inefficiency.

- vapi-client.js
  No action needed yet; The last expression is `vAPI.shutdown.add(...)`,
  which has a void return value.

- contentscript.js
  No action needed yet; The last expression is an immediately-invoked
  function expression without return value.
2018-05-01 07:28:21 -04:00
Raymond Hill 08495c42e9
complete "debian" as a target platform 2018-04-27 11:43:35 -04:00
Raymond Hill 3923520b87
remove no longer needed platform-dependent polyfill.js 2018-04-27 08:36:38 -04:00
Raymond Hill 9baf17fa2a
patch firefox/legacy for changes in e5f2e9701d 2018-04-26 12:01:31 -04:00