Commit Graph

151 Commits

Author SHA1 Message Date
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 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 08261e3c15
Change DOM surveyor to time-based processing logic (from chunk-based)
The DOM surveyor will now use time-based logic to spread its work
over time. This allows the surveying to better scale down on
slower devices.

Additionally, the DOM surveyor code has been reworked to lower as
much as possible memory churning when collating nodes to survey.

This rework has been motivated after profiling the "monstrous DOM"
seen in the following page:
<https://doc.rust-lang.org/std/iter/trait.Iterator.html>

The idea is that making the DOM surveyor efficient on such
"monstrous DOM" case should make it efficient everywhere in
practice.
2018-12-31 11:50:40 -05:00
Raymond Hill eb1428c8bb
Fix regression in the collapsing of blocked resources
Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/356
2018-12-27 10:17:08 -05:00
Raymond Hill 8a88e9d931
Support CSS selectors mixed w/ operators in procedural cosmetic filters
Related issue:
- https://github.com/gorhill/uBlock/issues/3683

This commit further increases uBO's procedural cosmetic filters
Adguard's cosmetic filter syntax -- specifically those procedural
cosmetic filters where plain CSS selectors appeared following
a procedural oeprator (this was rejected as invalid by uBO).

Also, experimental support for `:watch-attrs` procedural
operator, as discussed in <https://github.com/uBlockOrigin/uBlock-issues/issues/341#issuecomment-449765525>.
Support may be dropped before next release depending on whether
a better solution is suggested.

Additionally, the usual opportunistic refactoring toward ES6
syntax.
2018-12-26 10:45:19 -05:00
Raymond Hill d2a7ada0b0
fix https://github.com/uBlockOrigin/uBlock-issues/issues/341 2018-12-14 17:55:22 -05:00
Raymond Hill 8f05a2f8d3
fix https://github.com/uBlockOrigin/uBlock-issues/issues/341, and further work for https://github.com/gorhill/uBlock/issues/3683 2018-12-14 15:25:18 -05:00
Raymond Hill 3c85c03194
fix #308, #3436, https://github.com/uBlockOrigin/uBlock-issues/issues/155
<https://github.com/gorhill/uBlock/issues/3436>: a new per-site switch
has been added, no-scripting, which purpose is to wholly disable/enable
javascript for a given site. This new switch has precedence over all
other ways javascript can be disabled, including precedence over dynamic
filtering rules.

The popup panel will report the number of script resources which have
been seen by uBO for the current page. There is a minor inaccuracy to
be fixed regarding the count, and which fix requires to extend request
journaling.

<https://github.com/gorhill/uBlock/issues/308>: the `noscript` tags will
now be respected when the new no-scripting switch is in effect on a given
site.

A default setting has been added to the _Settings_ pane to
disable/enable globally the new no-script switch, such that one can
work in default-deny mode regarding javascript execution.

<https://github.com/uBlockOrigin/uBlock-issues/issues/155>: a new
hidden setting, `requestJournalProcessPeriod`, has been added to
allow controlling the delay before uBO internally process it's
network request journal queue. Default to 1000 (milliseconds).
2018-08-31 18:47:02 -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 0c5e2eb7ee
code review for c5d85881181a: mind about:blank et al. iframes 2018-05-20 06:49:12 -04:00
Raymond Hill b4306e3297
code reivew of c5d85881181a: immediate scriptlets injection works well only on Chromium-based browsers for now 2018-05-18 10:19:14 -04:00
Raymond Hill 04d84cf92a
fix #3397 2018-01-03 13:59:38 -05:00
Raymond Hill ec29c9a127
fix #3382 2017-12-31 16:05:23 -05:00
Raymond Hill 17dfec5759
fix #3372 2017-12-30 18:55:01 -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 ca8917149d
fix #3341 2017-12-13 08:02:55 -05:00
gorhill 958a7c20ed
fix #3335 2017-12-10 15:03:03 -05:00
gorhill 374e157b11
fix #3159 2017-11-14 15:03:20 -05:00
gorhill 2db377f577
code review: lower timer delay = less risk of large backlog 2017-10-31 06:47:39 -04:00
gorhill 25e2452722
code review: use for..of instead of for(..;..;..) 2017-10-28 16:50:44 -04:00
gorhill bbda2a9086
code review: preemptively address https://bugzilla.mozilla.org/show_bug.cgi?id=1408996#c9 2017-10-27 14:22:45 -04:00
gorhill 44ce44aa42
code review: early injection of lookred up generic cosmetic filters when possible 2017-10-26 06:18:03 -04:00
gorhill 6b65e3f406
code review: avoid reinjecting already injected low generic cosmetic filters 2017-10-25 11:42:18 -04:00
gorhill 9952e12aff
fine tune DOM surveyor 2017-10-24 16:38:51 -04:00
gorhill 2bea51cc63
fix silly regression regarding the DOM surveyor 2017-10-24 07:55:35 -04:00
gorhill a76f5b15ac
fix https://github.com/gorhill/uBlock/issues/3160#issuecomment-338509997 2017-10-23 12:21:37 -04:00
gorhill 6e18829f02
add to #2984: fix regressions, as per feedback and code review 2017-10-23 09:01:00 -04:00
gorhill 4f7aab695c
fix #3160 2017-10-22 08:59:29 -04:00
gorhill 6112a68faf
fix #2984 2017-10-21 13:43:46 -04:00
gorhill e7e390d2e2
fix #3077 2017-10-01 07:56:28 -04:00
gorhill 2660bee0d2
fix #2919 2017-09-05 19:49:48 -04:00
gorhill c31d29c2e3
fix bad test: regression from fdcc9515 2017-08-24 17:54:27 -04:00
gorhill 63be43a365
shield content script against exceptions in injected scriptlets 2017-08-21 12:04:35 -04:00
gorhill a1350b8cff
fix #2882 2017-08-17 09:54:01 -04:00
gorhill fdcc9515dc
fix #2029 2017-08-17 08:25:02 -04:00
gorhill d1c752da29
fix bad English in comment 2017-08-16 18:06:04 -04:00
gorhill 797082a36c
fix #2552 2017-08-16 14:10:41 -04:00
gorhill eb3519b075
fix #2839 2017-08-03 10:18:05 -04:00
gorhill 0d892a8856
fix #2810 2017-07-23 09:56:43 -04:00
gorhill d337abe504
minor code review 2017-06-22 14:36:45 -04:00
Sean Stangl 88fcf53d34 Check childElementCount directly. (#2725) 2017-06-21 20:09:19 -04:00
gorhill 139d97179f
as per #2612, use native Set() in content scripts 2017-05-15 08:51:25 -04:00
gorhill 8f42232105
fix #2609 2017-05-14 12:01:56 -04:00
gorhill 64c92a96a3
fix https://github.com/nikrolls/uBlock-Edge/issues/64 2017-03-16 19:31:14 -04:00
gorhill cf123b9264
fix #2448 2017-03-13 13:03:51 -04:00
gorhill 7a023077b3
performance work for pseudo-user styles code 2017-03-12 10:22:46 -04:00
gorhill 28084e1dc9 code review: marginal performance improvement 2017-02-12 15:53:40 -05:00
gorhill c6dbdbd23b code review of procedural cosmetic filters + better validate :style option (#2278) 2016-12-30 10:32:17 -05:00
gorhill 7558fedc38 fix typo in new :if/:if-not procedural operators 2016-12-26 12:37:43 -05:00
gorhill 73a69711f2 add chainable and recursive cosmetic procedural filters 2016-12-25 16:56:39 -05:00
gorhill 2f01fcda54 fix #2256 2016-12-21 11:44:03 -05:00
gorhill c39adacc50 better abstraction of user styles 2016-12-16 16:25:36 -05:00
gorhill 94637ee4ff fix https://github.com/nikrolls/uBlock-Edge/issues/30 2016-12-15 10:47:32 -05:00
gorhill 98d2bbada7 revise matches-css implementation as per #1930 and https://github.com/uBlockOrigin/uAssets/issues/212 2016-12-01 11:55:05 -05:00
gorhill cbf3dc9a0d maybe fix #2147 2016-11-12 13:38:41 -05:00
Nik Rolls be8e514464 Prevent possible error when a node has no children (#2108)
Compat with Edge; SVG nodes don't have a `children` property and therefore this throws an error whenever an SVG is added, removed or moved in the DOM.
2016-10-30 16:04:53 -04:00
gorhill cd81f866b9 code review: benefit from ES6 Set() in content script
fall back on legacy browser-specific polyfill code if required.
2016-10-09 11:09:25 -04:00
gorhill a1fa4d0fe9 fix #2060 2016-10-08 15:14:24 -04:00
gorhill b20b43e351 fix #2011: improve heuristic on when to give up on DOM surveying 2016-10-06 10:49:46 -04:00
gorhill 21f3dc83ec code review re. #1912 2016-09-24 14:42:31 -04:00
gorhill 0a15a95ad9 fix #1912 2016-09-22 12:18:01 -04:00
gorhill 33234fdd8b fix #1952 2016-08-31 17:50:49 -04:00
gorhill e6d1a1f896 fix #1927 (revised commit msg due to missing quote) 2016-08-22 19:14:37 -04:00
gorhill 17724b2fec code review re. `matches-css`: to support pseudo class `:after` 2016-08-19 08:46:39 -04:00
gorhill 48416bebee code review: minor fine tuning 2016-08-14 08:51:52 -04:00
gorhill fb7bd0cc1d fix #1893 2016-08-13 21:45:01 -04:00
gorhill e9157bafb7 fix #1892, #1891 2016-08-13 16:42:58 -04:00
gorhill 839fed43ae minor code review 2016-08-12 11:31:13 -04:00
gorhill 6fd0bb4291 more refactoring of content script: better modularization of various components 2016-08-12 08:55:35 -04:00
gorhill 8d35a05c05 code review re. 6fab1fe585 2016-08-08 19:41:53 -04:00
gorhill 6fab1fe585 code review domCollapser: avoid duplicates -- helps for https://bugzilla.mozilla.org/show_bug.cgi?id=1232354 2016-08-08 09:59:57 -04:00
gorhill 458b9758ef minor code review 2016-08-06 23:29:58 -04:00
gorhill 5d572f54de fix #1873 2016-08-06 21:07:05 -04:00
gorhill 372f4b4c86 minor code review 2016-08-06 12:09:18 -04:00
gorhill 16acbca1fa minor code review re. https://bugzilla.mozilla.org/show_bug.cgi?id=1232354 2016-08-06 10:20:11 -04:00
gorhill a5a9e0ce7c replace `csstext()` with more flexible/efficient `matches-css()` 2016-08-03 09:20:55 -04:00
gorhill 1ca285f8bd add new cosmetic operator `csstext()` 2016-08-03 08:06:51 -04:00
gorhill 0165d2e066 minor code review 2016-07-31 18:43:17 -04:00
gorhill 788ff0a21f code review: do not delay injection of specific cosmetic filters 2016-07-26 08:21:03 -04:00
gorhill 4da4709ed5 hopefully fix #1782: treat data: URI as 1st-party resources 2016-07-25 08:18:17 -04:00
gorhill 6895e6c7f9 minor code reivew: no need to scope to root for re-styling filters 2016-07-16 18:15:42 -04:00
gorhill 9e7fbb857b cosmetic filtering: stop surveying and/or filtering after too many consecutive misses 2016-07-12 13:29:30 -04:00
gorhill dce5487fc0 i need a vacation 2016-07-09 21:49:28 -04:00
gorhill 7e4e69fd84 returning self.Set was not a good idea 2016-07-09 21:40:07 -04:00
gorhill d12ae9277c fix silly bug from last commit (breaking Pale Moon) 2016-07-09 20:00:18 -04:00
gorhill 02e6b088ef further refactoring + performance: skip surveying DOM after too many empty resultset 2016-07-09 19:21:46 -04:00
gorhill 682e0c8916 fix #1773 2016-07-02 11:07:12 -04:00
gorhill 973d3e79c1 minor code review 2016-07-01 14:33:43 -04:00
gorhill 9d8499b4b1 fix #1770 2016-07-01 12:54:10 -04:00
gorhill 7f9c01d38f fix https://github.com/gorhill/uBlock/issues/769#issuecomment-229873048 and more completely #762 + dom inspector regressions 2016-07-01 08:09:48 -04:00
gorhill eabeedcd04 code review: use already available collections where possible 2016-07-01 06:44:02 -04:00
gorhill 8374799c7d various minor code review 2016-06-30 22:03:29 -04:00
gorhill a3f6a4186a instrumenting content scripts to make for easy profiling when needed 2016-06-30 16:10:38 -04:00
gorhill e6c38257be fix broken xpath operator + various code review 2016-06-30 10:23:38 -04:00
gorhill 87d0cce9b2 remove stray comma separator in injected CSS declarations 2016-06-29 18:12:21 -04:00
gorhill 3752ac4880 fix #781: support for explicit style properties 2016-06-29 17:07:33 -04:00
gorhill a5f7cbf969 new content script code: fix regression 2016-06-29 09:33:04 -04:00
gorhill e99d993a4c new content script code: perf work re. high-high generics
Now splitting high-high generics in two subgroups: one group for
simple selectors, another group for complex selectors. Turns out
the great majority of high-high generics are simple selectors, and
simple selectors can be applied incrementally with DOM changes, as
opposed to complex selectors. This brings in a significant perf.
improvement in the processing of high-high generics (previously,
all high-high generic selectors were processed as one big complex
selector).
2016-06-28 22:01:15 -04:00
gorhill b65699aef2 new content script code: code review, fine tuning perf 2016-06-28 19:45:11 -04:00
gorhill 2d68c8ee6c new content script code: code review, fine tuning perf 2016-06-28 09:06:14 -04:00