-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathbg.js
More file actions
23 lines (20 loc) · 728 Bytes
/
bg.js
File metadata and controls
23 lines (20 loc) · 728 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
chrome.webRequest.onBeforeSendHeaders.addListener(function(req){
var blocking_response = {};
// Determine whether to block this image request
var safe = req.url.indexOf('safe-img-pbza') > 0? true:false;
//Check if this request came from gmail
var from_gmail = false, headers = req.requestHeaders;
for(var i = 0; i < headers.length; i++) {
if(headers[i].name.toLowerCase() == 'referer'){
if(headers[i].value.indexOf('//mail.google.com/') > 0){
from_gmail = true;
break;
}
}
}
if(req.type == 'image' && !safe && from_gmail){
blocking_response.cancel = true;
}
return blocking_response;
},
{urls: [ "*://*.googleusercontent.com/proxy/*" ]},['requestHeaders','blocking']);