mirror of
https://github.com/gorhill/uBlock.git
synced 2024-11-02 00:42:45 +01:00
Move MutationObserver shim
Since it will be used only for older Safari versions, move it to Safari related code, so it doesn't pollute the content scripts.
This commit is contained in:
parent
36ad23a1db
commit
8f0b3cf592
@ -30,7 +30,7 @@
|
|||||||
|
|
||||||
if (vAPI.safari) {
|
if (vAPI.safari) {
|
||||||
if (!/^https?:/.test(location.protocol)) {
|
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;
|
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 = {
|
var ignoreTags = {
|
||||||
'link': true,
|
'link': true,
|
||||||
'LINK': true,
|
'LINK': true,
|
||||||
|
@ -197,6 +197,20 @@ if (self.chrome) {
|
|||||||
return;
|
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');
|
var beforeLoadEvent = document.createEvent('Event');
|
||||||
beforeLoadEvent.initEvent('beforeload');
|
beforeLoadEvent.initEvent('beforeload');
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user