diff --git a/src/js/contentscript-end.js b/src/js/contentscript-end.js index 871d93d76..03e2b2a21 100644 --- a/src/js/contentscript-end.js +++ b/src/js/contentscript-end.js @@ -30,7 +30,7 @@ if (vAPI.safari) { if (!/^https?:/.test(location.protocol)) { - throw "uBlock> contentscript-end.js > Skipping page: " + location.protocol + location.host; + throw "uBlock> contentscript-end.js > Skipping " + location.protocol; } } @@ -418,21 +418,6 @@ var messager = vAPI.messaging.channel('contentscript-end.js'); return; } - if (!window.MutationObserver) { - window.MutationObserver = window.WebKitMutationObserver || window.MozMutationObserver; - - // dummy shim for older browsers - if (!window.MutationObserver) { - window.MutationObserver = function(handler) { - this.observe = function(target) { - target.addEventListener('DOMNodeInserted', function(e) { - handler([{addedNodes: [e.target]}]); - }, true); - }; - } - } - } - var ignoreTags = { 'link': true, 'LINK': true, diff --git a/src/js/vapi-client.js b/src/js/vapi-client.js index b406713bc..69bd09c11 100644 --- a/src/js/vapi-client.js +++ b/src/js/vapi-client.js @@ -197,6 +197,20 @@ if (self.chrome) { return; } + window.MutationObserver = window.MutationObserver || window.WebKitMutationObserver; + + if (!window.MutationObserver) { + // dummy, minimalistic shim for older versions (<6) + // only supports node insertions, but currently we don't use it for anything else + window.MutationObserver = function(handler) { + this.observe = function(target) { + target.addEventListener('DOMNodeInserted', function(e) { + handler([{addedNodes: [e.target]}]); + }, true); + }; + } + } + var beforeLoadEvent = document.createEvent('Event'); beforeLoadEvent.initEvent('beforeload');