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-2015 Eyeo GmbH | 3 * Copyright (C) 2006-2015 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 |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 if (docDomain) | 129 if (docDomain) |
130 docDomain = docDomain.replace(/^www\./i, "").replace(/\.+$/, ""); | 130 docDomain = docDomain.replace(/^www\./i, "").replace(/\.+$/, ""); |
131 if (docDomain) | 131 if (docDomain) |
132 E("domainRestriction").value = docDomain; | 132 E("domainRestriction").value = docDomain; |
133 | 133 |
134 E("thirdParty").hidden = !thirdParty; | 134 E("thirdParty").hidden = !thirdParty; |
135 E("firstParty").hidden = thirdParty; | 135 E("firstParty").hidden = thirdParty; |
136 | 136 |
137 let typeGroup = E("typeGroup"); | 137 let typeGroup = E("typeGroup"); |
138 let defaultTypes = RegExpFilter.prototype.contentType & ~RegExpFilter.typeMap.
DOCUMENT; | 138 let defaultTypes = RegExpFilter.prototype.contentType & ~RegExpFilter.typeMap.
DOCUMENT; |
139 let isDefaultType = (RegExpFilter.typeMap[item.typeDescr] & defaultTypes) != 0
; | 139 let isDefaultType = (RegExpFilter.typeMap[item.type] & defaultTypes) != 0; |
140 for (let [type, label] of types) | 140 for (let [type, label] of types) |
141 { | 141 { |
142 if (type == "ELEMHIDE") | 142 if (type == "ELEMHIDE") |
143 continue; | 143 continue; |
144 | 144 |
145 let typeNode = document.createElement("checkbox"); | 145 let typeNode = document.createElement("checkbox"); |
146 typeNode.setAttribute("value", type.toLowerCase().replace(/\_/g, "-")); | 146 typeNode.setAttribute("value", type.toLowerCase().replace(/\_/g, "-")); |
147 typeNode.setAttribute("label", label); | 147 typeNode.setAttribute("label", label); |
148 | 148 |
149 let typeMask = RegExpFilter.typeMap[type]; | 149 let typeMask = RegExpFilter.typeMap[type]; |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 | 246 |
247 if (options.length) | 247 if (options.length) |
248 { | 248 { |
249 options.sort((a, b) => a[0] - b[0]); | 249 options.sort((a, b) => a[0] - b[0]); |
250 filter += "$" + options.map(o => o[1]).join(","); | 250 filter += "$" + options.map(o => o[1]).join(","); |
251 } | 251 } |
252 } | 252 } |
253 else | 253 else |
254 { | 254 { |
255 let defaultTypes = RegExpFilter.prototype.contentType & ~RegExpFilter.typeMa
p.DOCUMENT; | 255 let defaultTypes = RegExpFilter.prototype.contentType & ~RegExpFilter.typeMa
p.DOCUMENT; |
256 let isDefaultType = (RegExpFilter.typeMap[item.typeDescr] & defaultTypes) !=
0; | 256 let isDefaultType = (RegExpFilter.typeMap[item.type] & defaultTypes) != 0; |
257 if (!isDefaultType) | 257 if (!isDefaultType) |
258 filter += "$" + item.typeDescr.toLowerCase().replace(/\_/g, "-"); | 258 filter += "$" + item.type.toLowerCase().replace(/\_/g, "-"); |
259 } | 259 } |
260 | 260 |
261 filter = Filter.normalize(filter); | 261 filter = Filter.normalize(filter); |
262 E("regexpWarning").hidden = !Filter.regexpRegExp.test(filter); | 262 E("regexpWarning").hidden = !Filter.regexpRegExp.test(filter); |
263 | 263 |
264 let isSlow = false; | 264 let isSlow = false; |
265 let compiledFilter = Filter.fromText(filter); | 265 let compiledFilter = Filter.fromText(filter); |
266 if (E("regexpWarning").hidden) | 266 if (E("regexpWarning").hidden) |
267 { | 267 { |
268 if (compiledFilter instanceof RegExpFilter && defaultMatcher.isSlowFilter(co
mpiledFilter)) | 268 if (compiledFilter instanceof RegExpFilter && defaultMatcher.isSlowFilter(co
mpiledFilter)) |
269 isSlow = true; | 269 isSlow = true; |
270 } | 270 } |
271 E("shortpatternWarning").hidden = !isSlow; | 271 E("shortpatternWarning").hidden = !isSlow; |
272 | 272 |
273 E("matchWarning").hidden = compiledFilter instanceof RegExpFilter && compiledF
ilter.matches(item.location, RegExpFilter.typeMap[item.typeDescr], item.docDomai
n, item.thirdParty); | 273 E("matchWarning").hidden = compiledFilter instanceof RegExpFilter && compiledF
ilter.matches(item.location, RegExpFilter.typeMap[item.type], item.docDomain, it
em.thirdParty); |
274 | 274 |
275 E("filter").value = filter; | 275 E("filter").value = filter; |
276 } | 276 } |
277 | 277 |
278 function generateLinkText(element, replacement) | 278 function generateLinkText(element, replacement) |
279 { | 279 { |
280 let template = element.getAttribute("textTemplate"); | 280 let template = element.getAttribute("textTemplate"); |
281 if (typeof replacement != "undefined") | 281 if (typeof replacement != "undefined") |
282 template = template.replace(/\?1\?/g, replacement) | 282 template = template.replace(/\?1\?/g, replacement) |
283 | 283 |
(...skipping 18 matching lines...) Expand all Loading... |
302 pattern = E("customPattern").value; | 302 pattern = E("customPattern").value; |
303 } | 303 } |
304 else | 304 else |
305 { | 305 { |
306 E("anchorStart").checked = true; | 306 E("anchorStart").checked = true; |
307 E("anchorEnd").checked = false; | 307 E("anchorEnd").checked = false; |
308 } | 308 } |
309 | 309 |
310 function testFilter(/**String*/ filter) /**Boolean*/ | 310 function testFilter(/**String*/ filter) /**Boolean*/ |
311 { | 311 { |
312 return RegExpFilter.fromText(filter + "$" + item.typeDescr).matches(item.loc
ation, RegExpFilter.typeMap[item.typeDescr], item.docDomain, item.thirdParty); | 312 return RegExpFilter.fromText(filter + "$" + item.type).matches(item.location
, RegExpFilter.typeMap[item.type], item.docDomain, item.thirdParty); |
313 } | 313 } |
314 | 314 |
315 let anchorStartCheckbox = E("anchorStart"); | 315 let anchorStartCheckbox = E("anchorStart"); |
316 if (!/^\*/.test(pattern) && testFilter("||" + pattern)) | 316 if (!/^\*/.test(pattern) && testFilter("||" + pattern)) |
317 { | 317 { |
318 disableElement(anchorStartCheckbox, false, "checked", false); | 318 disableElement(anchorStartCheckbox, false, "checked", false); |
319 [anchorStartCheckbox.label, anchorStartCheckbox.accessKey] = Utils.splitLabe
l(anchorStartCheckbox.getAttribute("labelFlexible")); | 319 [anchorStartCheckbox.label, anchorStartCheckbox.accessKey] = Utils.splitLabe
l(anchorStartCheckbox.getAttribute("labelFlexible")); |
320 anchorStartCheckbox.flexibleAnchor = true; | 320 anchorStartCheckbox.flexibleAnchor = true; |
321 } | 321 } |
322 else | 322 else |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
394 * Selects or unselects all type checkboxes except those | 394 * Selects or unselects all type checkboxes except those |
395 * that are disabled. | 395 * that are disabled. |
396 */ | 396 */ |
397 function selectAllTypes(/**Boolean*/ select) | 397 function selectAllTypes(/**Boolean*/ select) |
398 { | 398 { |
399 for (let typeNode = E("typeGroup").firstChild; typeNode; typeNode = typeNode.n
extSibling) | 399 for (let typeNode = E("typeGroup").firstChild; typeNode; typeNode = typeNode.n
extSibling) |
400 if (typeNode.getAttribute("disabled") != "true") | 400 if (typeNode.getAttribute("disabled") != "true") |
401 typeNode.checked = select; | 401 typeNode.checked = select; |
402 updateFilter(); | 402 updateFilter(); |
403 } | 403 } |
OLD | NEW |