aboutsummaryrefslogtreecommitdiffstats
path: root/platform/safari
diff options
context:
space:
mode:
authorChris <chris@chrismatic.io>2015-02-22 21:59:21 -0700
committerChris <chris@chrismatic.io>2015-02-22 22:00:37 -0700
commit29fa6cb2e8ddd49fe8c2f51147d5c7e2aeb555e8 (patch)
tree0c6f4e31560e7db0b891bc0fe9b8b416003db8de /platform/safari
parent37aaeca8aa522011c2db4dea1e4ce5447287fb44 (diff)
downloaduBlock-29fa6cb2e8ddd49fe8c2f51147d5c7e2aeb555e8.zip
uBlock-29fa6cb2e8ddd49fe8c2f51147d5c7e2aeb555e8.tar.gz
uBlock-29fa6cb2e8ddd49fe8c2f51147d5c7e2aeb555e8.tar.bz2
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).
Diffstat (limited to 'platform/safari')
-rw-r--r--platform/safari/vapi-client.js16
1 files changed, 16 insertions, 0 deletions
diff --git a/platform/safari/vapi-client.js b/platform/safari/vapi-client.js
index 3eb57e9..b82bf99 100644
--- a/platform/safari/vapi-client.js
+++ b/platform/safari/vapi-client.js
@@ -188,6 +188,9 @@
return !(safari.self.tab.canLoad(beforeLoadEvent, details));
};
var onBeforeLoad = function(e) {
+ if(firstMutation !== false) {
+ firstMutation();
+ }
linkHelper.href = e.url;
if(linkHelper.protocol.charCodeAt(0) !== 104) { // h = 104
return;
@@ -232,7 +235,20 @@ return e.detail.url === false;\
},\
wo = open,\
xo = XMLHttpRequest.prototype.open,\
+img = Image;\
_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) {\
return block(u, 'popup') ? null : wo.apply(this, arguments);\
};\