Index: background.js |
=================================================================== |
--- a/background.js |
+++ b/background.js |
@@ -519,6 +519,55 @@ |
else |
sendResponse(false); |
break; |
+ case "can-block": |
+ var documentHost = extractHostFromFrame(sender.frame); |
+ |
+ if (isFrameWhitelisted(sender.page, sender.frame, "DOCUMENT")) |
+ { |
+ sendResponse({canBlock: false, reason: ext.i18n.getMessage("cannot_block_because_domain_whitelisted", documentHost)}); |
+ break; |
+ } |
+ |
+ var sitekey = getKey(sender.page, sender.frame); |
+ var exception = null; |
+ |
+ for (var i = 0; !exception && i < msg.urls.length; i++) |
+ { |
+ var requestHost = extractHostFromURL(msg.url); |
+ var thirdParty = isThirdParty(requestHost, documentHost); |
+ |
+ var filter = defaultMatcher.matchesAny(msg.urls[i], msg.mediatype, documentHost, thirdParty, sitekey); |
+ if (filter instanceof WhitelistFilter) |
+ exception = filter; |
+ } |
+ |
+ for (var i = 0; !exception && i < msg.elemHideFilters.length; i++) |
+ exception = ElemHide.getException(Filter.fromText(msg.elemHideFilters[i]), documentHost); |
+ |
+ if (exception) |
+ { |
+ var reason = ext.i18n.getMessage("cannot_block_because_exception_rule", exception.text); |
+ |
+ for (var i = 0; i < exception.subscriptions.length; i++) |
+ { |
+ var subscription = exception.subscriptions[i]; |
+ if (!subscription.disabled) |
+ { |
+ if (subscription.url == Prefs.subscriptions_exceptionsurl) |
+ reason = ext.i18n.getMessage("cannot_block_because_acceptable_ads"); |
+ else if (subscription.title) |
+ reason = ext.i18n.getMessage("cannot_block_because_exception_rule_with_origin", [exception.text, '"' + subscription.title + '"']); |
+ |
+ break; |
+ } |
+ } |
+ |
+ sendResponse({canBlock: false, reason: reason}); |
+ break; |
+ } |
+ |
+ sendResponse({canBlock: true}); |
+ break; |
case "get-domain-enabled-state": |
// Returns whether this domain is in the exclusion list. |
// The browser action popup asks us this. |