mirror of
https://github.com/gorhill/uBlock.git
synced 2024-10-06 09:37:12 +02:00
Safari: block programmatic image requests
Currently, this is done the same way we block XMLHttpRequests: mess with the constructor. This was done in the most efficient way I could think of (overhead is relatively minimal).
This commit is contained in:
parent
37aaeca8aa
commit
29fa6cb2e8
@ -188,6 +188,9 @@
|
|||||||
return !(safari.self.tab.canLoad(beforeLoadEvent, details));
|
return !(safari.self.tab.canLoad(beforeLoadEvent, details));
|
||||||
};
|
};
|
||||||
var onBeforeLoad = function(e) {
|
var onBeforeLoad = function(e) {
|
||||||
|
if(firstMutation !== false) {
|
||||||
|
firstMutation();
|
||||||
|
}
|
||||||
linkHelper.href = e.url;
|
linkHelper.href = e.url;
|
||||||
if(linkHelper.protocol.charCodeAt(0) !== 104) { // h = 104
|
if(linkHelper.protocol.charCodeAt(0) !== 104) { // h = 104
|
||||||
return;
|
return;
|
||||||
@ -232,7 +235,20 @@ return e.detail.url === false;\
|
|||||||
},\
|
},\
|
||||||
wo = open,\
|
wo = open,\
|
||||||
xo = XMLHttpRequest.prototype.open,\
|
xo = XMLHttpRequest.prototype.open,\
|
||||||
|
img = Image;\
|
||||||
_noOP = function(){};\
|
_noOP = function(){};\
|
||||||
|
window.Image = function() {\
|
||||||
|
var x = new img();\
|
||||||
|
Object.defineProperty(x, 'src', {\
|
||||||
|
get: function() {\
|
||||||
|
return x.getAttribute('src');\
|
||||||
|
},\
|
||||||
|
set: function(val) {\
|
||||||
|
x.setAttribute('src', block(val, 'image') ? 'data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=' : val);\
|
||||||
|
}\
|
||||||
|
});\
|
||||||
|
return x;\
|
||||||
|
};\
|
||||||
open = function(u) {\
|
open = function(u) {\
|
||||||
return block(u, 'popup') ? null : wo.apply(this, arguments);\
|
return block(u, 'popup') ? null : wo.apply(this, arguments);\
|
||||||
};\
|
};\
|
||||||
|
Loading…
Reference in New Issue
Block a user