| Index: include.preload.js |
| diff --git a/include.preload.js b/include.preload.js |
| index 1d4635a0da9fcda4266406564256e040e164b877..df6f9a105b52f0918f2c053a7b72dbb8f76df01b 100644 |
| --- a/include.preload.js |
| +++ b/include.preload.js |
| @@ -482,6 +482,36 @@ ElemHide.prototype = { |
| return shadow; |
| }, |
| + _insertRuleForSelectors(selectors) |
| + { |
| + const properties = " {display: none !important;}"; |
| + |
| + try |
| + { |
| + this.style.sheet.insertRule( |
| + selectors.join(", ") + properties, |
| + this.style.sheet.cssRules.length |
| + ); |
| + } |
| + catch (batchInsertException) |
| + { |
| + // There is a syntax error in one or more of the selectors. Rather than |
| + // dropping all of them let's add them invdividually, so that only the |
| + // broken selectors are skipped. |
| + for (let selector of selectors) |
| + { |
| + try |
| + { |
| + this.style.sheet.insertRule( |
| + selector + properties, |
| + this.style.sheet.cssRules.length |
| + ); |
| + } |
| + catch (individualInsertException) {} |
| + } |
| + } |
| + }, |
| + |
| addSelectors(selectors, filters) |
| { |
| if (selectors.length == 0) |
| @@ -528,11 +558,9 @@ ElemHide.prototype = { |
| // [1] - https://github.com/WebKit/webkit/blob/1cb2227f6b2a1035f7bdc46e5ab69debb75fc1de/Source/WebCore/css/RuleSet.h#L68 |
| for (let i = 0; i < preparedSelectors.length; i += this.selectorGroupSize) |
| { |
| - let selector = preparedSelectors.slice( |
| - i, i + this.selectorGroupSize |
| - ).join(", "); |
| - this.style.sheet.insertRule(selector + "{display: none !important;}", |
| - this.style.sheet.cssRules.length); |
| + this._insertRuleForSelectors( |
| + preparedSelectors.slice(i, i + this.selectorGroupSize) |
| + ); |
| } |
| if (this.tracer) |