Index: webrequest.js |
=================================================================== |
--- a/webrequest.js |
+++ b/webrequest.js |
@@ -26,27 +26,17 @@ function onBeforeRequest(details) |
if (type == "sub_frame") |
type = "SUBDOCUMENT"; |
else |
type = type.toUpperCase(); |
var frame = (type != "SUBDOCUMENT" ? details.frameId : details.parentFrameId); |
var filter = checkRequest(type, details.tabId, details.url, frame); |
if (filter instanceof BlockingFilter) |
- { |
- var collapse = filter.collapse; |
- if (collapse == null) |
- collapse = (localStorage["hidePlaceholders"] != "false"); |
- if (collapse && type == "SUBDOCUMENT") |
- return {redirectUrl: "about:blank"}; |
- else if (collapse && type == "IMAGE") |
- return {redirectUrl: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAACklEQVR4nGMAAQAABQABDQottAAAAABJRU5ErkJggg=="}; |
- else |
- return {cancel: true}; |
- } |
+ return {cancel: true}; |
else |
return {}; |
} |
function onHeadersReceived(details) |
{ |
if (details.tabId == -1) |
return; |
@@ -136,17 +126,35 @@ function checkRequest(type, tabId, url, |
var documentUrl = getFrameUrl(tabId, frameId); |
if (!documentUrl) |
return false; |
var requestHost = extractHostFromURL(url); |
var documentHost = extractHostFromURL(documentUrl); |
var thirdParty = isThirdParty(requestHost, documentHost); |
- return defaultMatcher.matchesAny(url, type, documentHost, thirdParty); |
+ var filter = defaultMatcher.matchesAny(url, type, documentHost, thirdParty); |
+ |
+ if (filter instanceof BlockingFilter) |
+ { |
+ var collapse = filter.collapse; |
+ if (collapse == null) |
+ collapse = (localStorage["hidePlaceholders"] != "false"); |
+ if (collapse && (type == "SUBDOCUMENT" || type == "IMAGE")) |
+ { |
+ chrome.tabs.sendMessage(tabId, { |
+ reqtype: "hide-element", |
+ type: type, |
+ url: url, |
+ documentUrl: documentUrl |
+ }); |
+ } |
+ } |
+ |
+ return filter; |
} |
function isFrameWhitelisted(tabId, frameId, type) |
{ |
var parent = frameId; |
while (parent != -1) |
{ |
var parentUrl = getFrameUrl(tabId, parent); |