Index: include.preload.js |
diff --git a/include.preload.js b/include.preload.js |
index 86e52c32afceb894f6591a84b0eca3b1842383ce..27b1229c07904935599647e23179bf5b931cc52c 100644 |
--- a/include.preload.js |
+++ b/include.preload.js |
@@ -194,7 +194,7 @@ function getContentDocument(element) |
function ElementHidingTracer(selectors) |
{ |
- this.selectors = selectors; |
+ this.selectors = selectors || []; |
Sebastian Noack
2017/01/11 16:20:40
It seems you removed the only code that initialize
wspee
2017/01/12 13:39:58
No longer relevant.
wspee
2017/01/19 16:20:14
Done.
|
this.changedNodes = []; |
this.timeout = null; |
@@ -219,7 +219,7 @@ ElementHidingTracer.prototype = { |
for (var j = 0; j < nodes.length; j++) |
{ |
- var elements = nodes[j].querySelectorAll(selector); |
+ var elements = nodes[j].querySelectorAll(selector.selector); |
var matched = false; |
for (var k = 0; k < elements.length; k++) |
@@ -229,7 +229,10 @@ ElementHidingTracer.prototype = { |
// priority, or haven't been circumvented in a different way. |
if (getComputedStyle(elements[k]).display == "none") |
{ |
- matchedSelectors.push(selector); |
+ if (selector.filter) |
+ matchedSelectors.push(selector.filter.replace(/^.*?##/, "")); |
+ else |
+ matchedSelectors.push(selector.selector); |
matched = true; |
break; |
} |
@@ -490,11 +493,31 @@ ElemHide.prototype = { |
return shadow; |
}, |
- addSelectors: function(selectors) |
+ addSelectors: function(selectors, filters) |
{ |
if (selectors.length == 0) |
return; |
+ if (this.tracer != null) |
+ { |
+ // The selector is beeing used to identify the filter that is responsible |
+ // for hiding a particular element in the devtools panel. The |
+ // ElementHidingTracer uses the selector to figure out if a filter is |
+ // used on the current document. In case of an ElemHideEmulationFilter |
+ // the selector doesn't match the selector of the filter |
+ // ([-abp-properties=...] vs actual css selector depending on the sites |
+ // css). The To still allow the devtools panel to find the correct filter |
+ // we pass both the selector and the filter string to the |
+ // ElementHidingTracer. |
+ for (var i = 0; i < selectors.length; i++) |
+ { |
+ this.tracer.selectors.push({ |
Sebastian Noack
2017/01/11 16:20:40
Is it guaranteed that the order of selectors match
Sebastian Noack
2017/01/11 16:20:40
Creating a new object for each selector might pote
wspee
2017/01/12 13:39:58
Indeed ... if you look at findSelectors there can
wspee
2017/01/12 13:39:58
No longer relevant.
wspee
2017/01/19 16:20:14
According to the chrome profiler an array with 100
wspee
2017/01/19 16:20:14
Done.
|
+ selector: selectors[i], |
+ filter: filters ? filters[i] : null |
+ }); |
+ } |
+ } |
+ |
if (!this.style) |
{ |
// Create <style> element lazily, only if we add styles. Add it to |
@@ -544,38 +567,32 @@ ElemHide.prototype = { |
apply: function() |
{ |
var selectors = null; |
- var elemHideEmulationLoaded = false; |
var checkLoaded = function() |
{ |
- if (!selectors || !elemHideEmulationLoaded) |
- return; |
- |
if (this.tracer) |
this.tracer.disconnect(); |
this.tracer = null; |
+ if (selectors.trace) |
+ this.tracer = new ElementHidingTracer(); |
+ |
if (this.style && this.style.parentElement) |
this.style.parentElement.removeChild(this.style); |
this.style = null; |
- this.addSelectors(selectors.selectors); |
+ if (selectors.selectors) |
+ this.addSelectors(selectors.selectors); |
this.elemHideEmulation.apply(); |
- if (selectors.trace) |
- this.tracer = new ElementHidingTracer(selectors.selectors); |
+ if (this.tracer && this.tracer.selectors.length) |
Sebastian Noack
2017/01/11 16:20:40
Any particular reason (except for a hypothetical m
wspee
2017/01/12 13:39:58
No longer relevant.
wspee
2017/01/19 16:20:15
Done.
|
+ this.tracer.checkNodes([document]); |
}.bind(this); |
- ext.backgroundPage.sendMessage({type: "get-selectors"}, function(response) |
+ ext.backgroundPage.sendMessage({type: "get-selectors"}, (response) => |
Sebastian Noack
2017/01/11 16:20:40
The parentheses around the "response" argument are
wspee
2017/01/12 13:39:58
No longer relevant.
wspee
2017/01/19 16:20:14
Done.
|
{ |
selectors = response; |
- checkLoaded(); |
- }); |
- |
- this.elemHideEmulation.load(function() |
- { |
- elemHideEmulationLoaded = true; |
- checkLoaded(); |
+ this.elemHideEmulation.load(() => { checkLoaded(); }); |
Sebastian Noack
2017/01/11 16:20:40
The arrow function seems redundant. Why not just p
wspee
2017/01/12 13:39:58
No longer relevant.
wspee
2017/01/19 16:20:14
Done.
|
}); |
} |
}; |