From 58ae9f266b600be3a7fe9fb7420af8db41c02c2c 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, more thorough XHR 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 also injects uBlock's blocking interceptor earlier, thusly covering more requests that may have slipped through before. --- platform/safari/vapi-client.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/platform/safari/vapi-client.js b/platform/safari/vapi-client.js index b82bf992a..a6d5d1481 100644 --- a/platform/safari/vapi-client.js +++ b/platform/safari/vapi-client.js @@ -237,15 +237,15 @@ wo = open,\ xo = XMLHttpRequest.prototype.open,\ img = Image;\ _noOP = function(){};\ -window.Image = function() {\ +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);\ - }\ +get: function() {\ +return x.getAttribute('src');\ +},\ +set: function(val) {\ +x.setAttribute('src', block(val, 'image') ? 'data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=' : val);\ +}\ });\ return x;\ };\