Index: include.preload.js |
diff --git a/include.preload.js b/include.preload.js |
index f4ab60be781c88c27079d7df6f1c4e77a430188d..0397c82c7a0036d8774807f2013f9b9dd04470be 100644 |
--- a/include.preload.js |
+++ b/include.preload.js |
@@ -334,32 +334,53 @@ ElementHidingTracer.prototype = { |
} |
}; |
+function runInPage(fn, arg) |
+{ |
+ var script = document.createElement("script"); |
+ script.type = "application/javascript"; |
+ script.async = false; |
+ script.textContent = "(" + fn + ")(" + JSON.stringify(arg) + ");"; |
+ document.documentElement.appendChild(script); |
+ document.documentElement.removeChild(script); |
+} |
+ |
function reinjectStyleSheetWhenRemoved(document, style) |
{ |
if (!MutationObserver) |
return null; |
+ var rules = style.sheet.rules; |
var parentNode = style.parentNode; |
var observer = new MutationObserver(function() |
{ |
if (style.parentNode != parentNode) |
+ { |
parentNode.appendChild(style); |
+ |
+ if (style.sheet.rules.length == 0) |
+ { |
+ for (var i = 0; i < rules.length; i++) |
+ style.sheet.addRule(rules[i].selectorText, "display: none !important;"); |
+ |
+ style.id = id; |
+ runInPage( |
+ function(id) |
+ { |
+ var style = document.getElementById(id) || |
+ document.documentElement.shadowRoot.getElementById(id); |
+ style.removeAttribute("id"); |
+ Object.defineProperty(style.sheet, "disabled", |
+ {value: false, enumerable: true}); |
+ }, id |
+ ); |
+ } |
+ } |
}); |
observer.observe(parentNode, {childList: true}); |
return observer; |
} |
-function runInPage(fn, arg) |
-{ |
- var script = document.createElement("script"); |
- script.type = "application/javascript"; |
- script.async = false; |
- script.textContent = "(" + fn + ")(" + JSON.stringify(arg) + ");"; |
- document.documentElement.appendChild(script); |
- document.documentElement.removeChild(script); |
-} |
- |
function protectStyleSheet(document, style) |
{ |
style.id = id; |