Left: | ||
Right: |
OLD | NEW |
---|---|
1 /* | 1 /* |
2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
3 * Copyright (C) 2006-2016 Eyeo GmbH | 3 * Copyright (C) 2006-2016 Eyeo GmbH |
4 * | 4 * |
5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
8 * | 8 * |
9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
13 * | 13 * |
14 * You should have received a copy of the GNU General Public License | 14 * You should have received a copy of the GNU General Public License |
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. | 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
16 */ | 16 */ |
17 | 17 |
18 "use strict"; | 18 "use strict"; |
19 | 19 |
20 function generateFilter(request) | 20 function generateFilter(request, domainSpecific) |
21 { | 21 { |
22 var filter = request.url.replace(/^[\w\-]+:\/+(?:www\.)?/, "||"); | 22 var filter = request.url.replace(/^[\w\-]+:\/+(?:www\.)?/, "||"); |
23 var options = []; | |
23 | 24 |
24 if (request.type == "POPUP") | 25 if (request.type == "POPUP") |
25 { | 26 { |
26 filter += "$popup"; | 27 options.push("popup"); |
27 | 28 |
28 if (request.url == "about:blank") | 29 if (request.url == "about:blank") |
29 filter += ",domain=" + request.docDomain; | 30 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
| |
30 } | 31 } |
31 | 32 |
33 if (domainSpecific) | |
34 options.push("domain=" + request.docDomain); | |
35 | |
36 if (options.length > 0) | |
37 filter += "$" + options.join(","); | |
38 | |
32 return filter; | 39 return filter; |
33 } | 40 } |
34 | 41 |
35 function createActionButton(action, label, filter) | 42 function createActionButton(action, label, filter) |
36 { | 43 { |
37 var button = document.createElement("span"); | 44 var button = document.createElement("span"); |
38 | 45 |
39 button.textContent = label; | 46 button.textContent = label; |
40 button.classList.add("action"); | 47 button.classList.add("action"); |
41 | 48 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
89 { | 96 { |
90 if (filter.userDefined) | 97 if (filter.userDefined) |
91 originElement.textContent = "user-defined"; | 98 originElement.textContent = "user-defined"; |
92 else | 99 else |
93 originElement.textContent = "unnamed subscription"; | 100 originElement.textContent = "unnamed subscription"; |
94 | 101 |
95 originElement.classList.add("unnamed"); | 102 originElement.classList.add("unnamed"); |
96 } | 103 } |
97 | 104 |
98 if (!filter.whitelisted && request.type != "ELEMHIDE") | 105 if (!filter.whitelisted && request.type != "ELEMHIDE") |
99 actionWrapper.appendChild(createActionButton("add", "Add exception", "@@" + generateFilter(request))); | 106 actionWrapper.appendChild(createActionButton( |
107 "add", "Add exception", "@@" + generateFilter(request, false) | |
108 )); | |
100 | 109 |
101 if (filter.userDefined) | 110 if (filter.userDefined) |
102 actionWrapper.appendChild(createActionButton("remove", "Remove rule", filt er.text)); | 111 actionWrapper.appendChild(createActionButton( |
112 "remove", "Remove rule", filter.text | |
113 )); | |
103 } | 114 } |
104 else | 115 else |
105 actionWrapper.appendChild(createActionButton("add", "Block item", generateFi lter(request))); | 116 actionWrapper.appendChild(createActionButton( |
117 "add", "Block item", generateFilter(request, request.specificOnly) | |
118 )); | |
106 | 119 |
107 return row; | 120 return row; |
108 } | 121 } |
109 | 122 |
110 document.addEventListener("DOMContentLoaded", function() | 123 document.addEventListener("DOMContentLoaded", function() |
111 { | 124 { |
112 var container = document.getElementById("items"); | 125 var container = document.getElementById("items"); |
113 var table = container.querySelector("tbody"); | 126 var table = container.querySelector("tbody"); |
114 var template = document.querySelector("template").content.firstElementChild; | 127 var template = document.querySelector("template").content.firstElementChild; |
115 | 128 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
150 container.classList.add("has-changes"); | 163 container.classList.add("has-changes"); |
151 break; | 164 break; |
152 | 165 |
153 case "reset": | 166 case "reset": |
154 table.innerHTML = ""; | 167 table.innerHTML = ""; |
155 container.classList.remove("has-changes"); | 168 container.classList.remove("has-changes"); |
156 break; | 169 break; |
157 } | 170 } |
158 }); | 171 }); |
159 }, false); | 172 }, false); |
OLD | NEW |