From 29fa6cb2e8ddd49fe8c2f51147d5c7e2aeb555e8 Mon Sep 17 00:00:00 2001 From: Chris Date: Sun, 22 Feb 2015 21:59:21 -0700 Subject: [PATCH] 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). --- platform/safari/vapi-client.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/platform/safari/vapi-client.js b/platform/safari/vapi-client.js index 3eb57e954..b82bf992a 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);\ };\