Index: include.preload.js |
=================================================================== |
--- a/include.preload.js |
+++ b/include.preload.js |
@@ -30,16 +30,26 @@ |
["audio", "MEDIA"], |
["video", "MEDIA"], |
["frame", "SUBDOCUMENT"], |
["iframe", "SUBDOCUMENT"], |
["object", "OBJECT"], |
["embed", "OBJECT"] |
]); |
+let emulatedSelectors = []; |
Sebastian Noack
2018/03/06 20:17:39
Shouldn't this rather be a property on the ElemHid
Manish Jethani
2018/03/07 06:23:04
Done.
|
+ |
+function haveSelectorsChanged(selectors, oldSelectors) |
+{ |
+ if (selectors.length != oldSelectors.length) |
+ return true; |
+ |
+ return !selectors.every((selector, index) => selector == oldSelectors[index]); |
+} |
+ |
function getURLsFromObjectElement(element) |
{ |
let url = element.getAttribute("data"); |
if (url) |
return [url]; |
for (let child of element.children) |
{ |
@@ -449,16 +459,21 @@ |
).join(", "); |
style.sheet.insertRule(selector + "{display: none !important;}", |
style.sheet.cssRules.length); |
} |
}, |
addSelectors(selectors, filters) |
{ |
+ if (!haveSelectorsChanged(selectors, emulatedSelectors)) |
+ return; |
+ |
+ emulatedSelectors = selectors; |
+ |
if (this.inline || this.inlineEmulated) |
{ |
// Insert the style rules inline if we have been instructed by the |
// background page to do so. This is usually the case, except on platforms |
// that do support user stylesheets via the browser.tabs.insertCSS API |
// (Firefox 53 onwards for now and possibly Chrome in the near future). |
// Once all supported platforms have implemented this API, we can remove |
// the code below. See issue #5090. |