| Index: include.preload.js |
| =================================================================== |
| --- a/include.preload.js |
| +++ b/include.preload.js |
| @@ -391,127 +391,75 @@ |
| document.removeEventListener("DOMContentLoaded", this.trace); |
| this.observer.disconnect(); |
| clearTimeout(this.timeout); |
| } |
| }; |
| function ContentFiltering() |
| { |
| - this.shadow = this.createShadowTree(); |
| this.styles = new Map(); |
| this.tracer = null; |
| this.inline = true; |
| this.inlineEmulated = true; |
| this.elemHideEmulation = new ElemHideEmulation( |
| this.addSelectors.bind(this), |
| this.hideElements.bind(this) |
| ); |
| } |
| ContentFiltering.prototype = { |
| selectorGroupSize: 1024, |
| - createShadowTree() |
| - { |
| - // Use Shadow DOM if available as to not mess with with web pages that |
| - // rely on the order of their own <style> tags (#309). However, creating |
| - // a shadow root breaks running CSS transitions. So we have to create |
| - // the shadow root before transistions might start (#452). |
| - if (!("createShadowRoot" in document.documentElement)) |
| - return null; |
| - |
| - // Both Firefox and Chrome 66+ support user style sheets, so we can avoid |
| - // creating an unnecessary shadow root on these platforms. |
| - let match = /\bChrome\/(\d+)/.exec(navigator.userAgent); |
| - if (!match || match[1] >= 66) |
| - return null; |
| - |
| - // Using shadow DOM causes issues on some Google websites, |
| - // including Google Docs, Gmail and Blogger (#1770, #2602, #2687). |
| - if (/\.(?:google|blogger)\.com$/.test(document.domain)) |
| - return null; |
| - |
| - // Finally since some users have both AdBlock and Adblock Plus installed we |
| - // have to consider how the two extensions interact. For example we want to |
| - // avoid creating the shadowRoot twice. |
| - let shadow = document.documentElement.shadowRoot || |
| - document.documentElement.createShadowRoot(); |
| - shadow.appendChild(document.createElement("content")); |
| - |
| - return shadow; |
| - }, |
| - |
| addSelectorsInline(selectors, groupName, appendOnly = false) |
| { |
| let style = this.styles.get(groupName); |
| if (style && !appendOnly) |
| { |
| while (style.sheet.cssRules.length > 0) |
| style.sheet.deleteRule(0); |
| } |
| if (selectors.length == 0) |
| return; |
| if (!style) |
| { |
| // Create <style> element lazily, only if we add styles. Add it to |
| - // the shadow DOM if possible. Otherwise fallback to the <head> or |
| - // <html> element. If we have injected a style element before that |
| - // has been removed (the sheet property is null), create a new one. |
| + // the <head> or <html> element. If we have injected a style element |
| + // before that has been removed (the sheet property is null), create a |
| + // new one. |
| style = document.createElement("style"); |
| - (this.shadow || document.head || |
| - document.documentElement).appendChild(style); |
| + (document.head || document.documentElement).appendChild(style); |
| // It can happen that the frame already navigated to a different |
| // document while we were waiting for the background page to respond. |
| - // In that case the sheet property will stay null, after addind the |
| - // <style> element to the shadow DOM. |
| + // In that case the sheet property may stay null, after adding the |
| + // <style> element. |
| if (!style.sheet) |
| return; |
| this.styles.set(groupName, style); |
| } |
| - // If using shadow DOM, we have to add the ::content pseudo-element |
| - // before each selector, in order to match elements within the |
| - // insertion point. |
| - let preparedSelectors = []; |
| - if (this.shadow) |
| - { |
| - for (let selector of selectors) |
| - { |
| - let subSelectors = splitSelector(selector); |
| - for (let subSelector of subSelectors) |
| - preparedSelectors.push("::content " + subSelector); |
| - } |
| - } |
| - else |
| - { |
| - preparedSelectors = selectors; |
| - } |
| - |
| // Chromium's Blink engine supports only up to 8,192 simple selectors, and |
| // even fewer compound selectors, in a rule. The exact number of selectors |
| // that would work depends on their sizes (e.g. "#foo .bar" has a |
| // size of 2). Since we don't know the sizes of the selectors here, we |
| // simply split them into groups of 1,024, based on the reasonable |
| // assumption that the average selector won't have a size greater than 8. |
| // The alternative would be to calculate the sizes of the selectors and |
| // divide them up accordingly, but this approach is more efficient and has |
| // worked well in practice. In theory this could still lead to some |
| // selectors not working on Chromium, but it is highly unlikely. |
| // See issue #6298 and https://crbug.com/804179 |
| - for (let i = 0; i < preparedSelectors.length; i += this.selectorGroupSize) |
| + for (let i = 0; i < selectors.length; i += this.selectorGroupSize) |
| { |
| - let selector = preparedSelectors.slice( |
| - i, i + this.selectorGroupSize |
| - ).join(", "); |
| + let selector = selectors.slice(i, i + this.selectorGroupSize).join(", "); |
| style.sheet.insertRule(selector + "{display: none !important;}", |
| style.sheet.cssRules.length); |
| } |
| }, |
| addSelectors(selectors, filters, groupName = "emulated", appendOnly = false) |
| { |
| if (this.inline || this.inlineEmulated) |