| Index: include.preload.js |
| =================================================================== |
| --- a/include.preload.js |
| +++ b/include.preload.js |
| @@ -30,16 +30,24 @@ |
| ["audio", "MEDIA"], |
| ["video", "MEDIA"], |
| ["frame", "SUBDOCUMENT"], |
| ["iframe", "SUBDOCUMENT"], |
| ["object", "OBJECT"], |
| ["embed", "OBJECT"] |
| ]); |
| +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) |
| { |
| @@ -342,16 +350,17 @@ |
| function ElemHide() |
| { |
| this.shadow = this.createShadowTree(); |
| this.styles = new Map(); |
| this.tracer = null; |
| this.inline = true; |
| this.inlineEmulated = true; |
| this.emulatedPatterns = null; |
| + this.emulatedSelectors = []; |
| this.elemHideEmulation = new ElemHideEmulation( |
| this.addSelectors.bind(this), |
| this.hideElements.bind(this) |
| ); |
| } |
| ElemHide.prototype = { |
| selectorGroupSize: 1024, |
| @@ -449,16 +458,21 @@ |
| ).join(", "); |
| style.sheet.insertRule(selector + "{display: none !important;}", |
| style.sheet.cssRules.length); |
| } |
| }, |
| addSelectors(selectors, filters) |
| { |
| + if (!haveSelectorsChanged(selectors, this.emulatedSelectors)) |
| + return; |
| + |
| + this.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. |