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

Unified Diff: devtools-panel.js

Issue 29335396: Issue 154 - Make the devtools panel generate domain specific filters when $genericblock is active (Closed)
Patch Set: Created Feb. 3, 2016, 9:57 a.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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: devtools-panel.js
===================================================================
--- a/devtools-panel.js
+++ b/devtools-panel.js
@@ -17,18 +17,25 @@
"use strict";
-function generateFilter(request)
+function generateFilter(request, domainSpecific)
{
var filter = request.url.replace(/^[\w\-]+:\/+(?:www\.)?/, "||");
+ var options = [];
if (request.type == "POPUP")
{
- filter += "$popup";
+ options.push("popup");
if (request.url == "about:blank")
- filter += ",domain=" + request.docDomain;
+ domainSpecific = true;
kzar 2016/02/03 10:27:17 Nit: `domainSpecific = domainSpecific || request.u
Sebastian Noack 2016/02/03 10:35:27 No, that's only if it's a popup.
kzar 2016/02/03 10:40:27 Acknowledged. Though the first suggestion still st
}
+ if (domainSpecific)
+ options.push("domain=" + request.docDomain);
+
+ if (options.length > 0)
+ filter += "$" + options.join(",");
+
return filter;
}
@@ -96,13 +103,19 @@
}
if (!filter.whitelisted && request.type != "ELEMHIDE")
- actionWrapper.appendChild(createActionButton("add", "Add exception", "@@" + generateFilter(request)));
+ actionWrapper.appendChild(createActionButton(
+ "add", "Add exception", "@@" + generateFilter(request, false)
+ ));
if (filter.userDefined)
- actionWrapper.appendChild(createActionButton("remove", "Remove rule", filter.text));
+ actionWrapper.appendChild(createActionButton(
+ "remove", "Remove rule", filter.text
+ ));
}
else
- actionWrapper.appendChild(createActionButton("add", "Block item", generateFilter(request)));
+ actionWrapper.appendChild(createActionButton(
+ "add", "Block item", generateFilter(request, request.specificOnly)
+ ));
return row;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld