Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: include.postload.js

Issue 5788069215076352: Issue 1282 - Show error message when user tries to block whitelisted elements (Closed)
Patch Set: Created Dec. 13, 2014, 1:42 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « background.js ('k') | include.preload.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include.postload.js
===================================================================
--- a/include.postload.js
+++ b/include.postload.js
@@ -506,15 +506,19 @@
if (currentElement.classList.contains("__adblockplus__overlay"))
elt = currentElement.prisoner;
- clickHideFilters = new Array();
- selectorList = new Array();
+ clickHideFilters = [];
+ elemHideFilters = [];
+ selectorList = [];
var addSelector = function(selector)
{
if (selectorList.indexOf(selector) != -1)
return;
- clickHideFilters.push(document.domain + "##" + selector);
+ var filter = document.domain + "##" + selector;
+ clickHideFilters.push(filter);
+ elemHideFilters.push(filter);
+
selectorList.push(selector);
};
@@ -558,14 +562,34 @@
addSelector(escapeCSS(elt.localName) + '[style=' + quote(style) + ']');
}
- // Show popup
- clickHide_showDialog(e.clientX, e.clientY, clickHideFilters);
+ ext.backgroundPage.sendMessage(
+ {
+ type: "can-block",
+ urls: urls,
+ mediatype: typeMap[elt.localName],
+ elemHideFilters: elemHideFilters
+ },
- // Highlight the elements specified by selector in yellow
- if (selectorList.length > 0)
- highlightElements(selectorList.join(","));
- // Now, actually highlight the element the user clicked on in red
- highlightElement(currentElement, "#fd1708", "#f6a1b5");
+ function(response)
+ {
+ if (response.canBlock)
+ {
+ clickHide_showDialog(e.clientX, e.clientY, clickHideFilters);
+
+ // Highlight the elements specified by selector in yellow
+ if (selectorList.length > 0)
+ highlightElements(selectorList.join(","));
+
+ // Now, actually highlight the element the user clicked on in red
+ highlightElement(currentElement, "#fd1708", "#f6a1b5");
+ }
+ else
+ {
+ clickHide_deactivate();
+ alert(response.reason);
+ }
+ }
+ );
// Make sure the browser doesn't handle this click
e.preventDefault();
« no previous file with comments | « background.js ('k') | include.preload.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld