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 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
388 E("contextDisableFilter").hidden = true; | 388 E("contextDisableFilter").hidden = true; |
389 E("contextEnableFilter").hidden = true; | 389 E("contextEnableFilter").hidden = true; |
390 E("contextDisableOnSite").hidden = true; | 390 E("contextDisableOnSite").hidden = true; |
391 if ("filter" in item && item.filter) | 391 if ("filter" in item && item.filter) |
392 { | 392 { |
393 let filter = item.filter; | 393 let filter = item.filter; |
394 let menuItem = E(filter.disabled ? "contextEnableFilter" : "contextDisableFi
lter"); | 394 let menuItem = E(filter.disabled ? "contextEnableFilter" : "contextDisableFi
lter"); |
395 menuItem.setAttribute("label", menuItem.getAttribute("labeltempl").replace(/
\?1\?/, filter.text)); | 395 menuItem.setAttribute("label", menuItem.getAttribute("labeltempl").replace(/
\?1\?/, filter.text)); |
396 menuItem.hidden = false; | 396 menuItem.hidden = false; |
397 | 397 |
398 if (filter instanceof ActiveFilter && !filter.disabled && filter.subscriptio
ns.length && !filter.subscriptions.some(function(subscription) !(subscription in
stanceof SpecialSubscription))) | 398 if (filter instanceof ActiveFilter && !filter.disabled && filter.subscriptio
ns.length && !filter.subscriptions.some(subscription => !(subscription instanceo
f SpecialSubscription))) |
399 { | 399 { |
400 let domain = null; | 400 let domain = null; |
401 try { | 401 try { |
402 domain = Utils.effectiveTLD.getBaseDomainFromHost(item.docDomain); | 402 domain = Utils.effectiveTLD.getBaseDomainFromHost(item.docDomain); |
403 } catch (e) {} | 403 } catch (e) {} |
404 | 404 |
405 if (domain && !filter.isActiveOnlyOnDomain(domain)) | 405 if (domain && !filter.isActiveOnlyOnDomain(domain)) |
406 { | 406 { |
407 menuItem = E("contextDisableOnSite"); | 407 menuItem = E("contextDisableOnSite"); |
408 menuItem.setAttribute("label", menuItem.getAttribute("labeltempl").repla
ce(/\?1\?/, domain)); | 408 menuItem.setAttribute("label", menuItem.getAttribute("labeltempl").repla
ce(/\?1\?/, domain)); |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
519 treeView.boxObject.invalidate(); | 519 treeView.boxObject.invalidate(); |
520 } | 520 } |
521 | 521 |
522 /** | 522 /** |
523 * Edits the filter to disable it on a particular domain. | 523 * Edits the filter to disable it on a particular domain. |
524 */ | 524 */ |
525 function disableOnSite() | 525 function disableOnSite() |
526 { | 526 { |
527 let item = treeView.getSelectedItem(); | 527 let item = treeView.getSelectedItem(); |
528 let filter = item.filter; | 528 let filter = item.filter; |
529 if (!(filter instanceof ActiveFilter) || filter.disabled || !filter.subscripti
ons.length || filter.subscriptions.some(function(subscription) !(subscription in
stanceof SpecialSubscription))) | 529 if (!(filter instanceof ActiveFilter) || filter.disabled || !filter.subscripti
ons.length || filter.subscriptions.some(subscription => !(subscription instanceo
f SpecialSubscription))) |
530 return; | 530 return; |
531 | 531 |
532 let domain; | 532 let domain; |
533 try { | 533 try { |
534 domain = Utils.effectiveTLD.getBaseDomainFromHost(item.docDomain).toUpperCas
e(); | 534 domain = Utils.effectiveTLD.getBaseDomainFromHost(item.docDomain).toUpperCas
e(); |
535 } | 535 } |
536 catch (e) | 536 catch (e) |
537 { | 537 { |
538 return; | 538 return; |
539 } | 539 } |
540 | 540 |
541 // Generate text for new filter that excludes current domain | 541 // Generate text for new filter that excludes current domain |
542 let text = filter.text; | 542 let text = filter.text; |
543 if (filter instanceof RegExpFilter) | 543 if (filter instanceof RegExpFilter) |
544 { | 544 { |
545 let match = Filter.optionsRegExp.exec(text); | 545 let match = Filter.optionsRegExp.exec(text); |
546 if (match) | 546 if (match) |
547 { | 547 { |
548 let found = false; | 548 let found = false; |
549 let options = match[1].toUpperCase().split(","); | 549 let options = match[1].toUpperCase().split(","); |
550 for (let i = 0; i < options.length; i++) | 550 for (let i = 0; i < options.length; i++) |
551 { | 551 { |
552 let match = /^DOMAIN=(.*)/.exec(options[i]); | 552 let match = /^DOMAIN=(.*)/.exec(options[i]); |
553 if (match) | 553 if (match) |
554 { | 554 { |
555 let domains = match[1].split("|").filter(function(d) d != domain && d
!= "~" + domain && (d.length <= domain.length || d.lastIndexOf("." + domain) !=
d.length - domain.length - 1)); | 555 let domains = match[1].split("|").filter(d => d != domain && d != "~"
+ domain && (d.length <= domain.length || d.lastIndexOf("." + domain) != d.lengt
h - domain.length - 1)); |
556 domains.push("~" + domain); | 556 domains.push("~" + domain); |
557 options[i] = "DOMAIN=" + domains.join("|"); | 557 options[i] = "DOMAIN=" + domains.join("|"); |
558 found = true; | 558 found = true; |
559 break; | 559 break; |
560 } | 560 } |
561 } | 561 } |
562 if (!found) | 562 if (!found) |
563 options.push("DOMAIN=~" + domain); | 563 options.push("DOMAIN=~" + domain); |
564 | 564 |
565 text = text.replace(Filter.optionsRegExp, "$" + options.join(",").toLowerC
ase()); | 565 text = text.replace(Filter.optionsRegExp, "$" + options.join(",").toLowerC
ase()); |
566 } | 566 } |
567 else | 567 else |
568 text += "$domain=~" + domain.toLowerCase(); | 568 text += "$domain=~" + domain.toLowerCase(); |
569 } | 569 } |
570 else if (filter instanceof ElemHideBase) | 570 else if (filter instanceof ElemHideBase) |
571 { | 571 { |
572 let match = /^([^#]+)(#.*)/.exec(text); | 572 let match = /^([^#]+)(#.*)/.exec(text); |
573 if (match) | 573 if (match) |
574 { | 574 { |
575 let selector = match[2]; | 575 let selector = match[2]; |
576 let domains = match[1].toUpperCase().split(",").filter(function(d) d != do
main && (d.length <= domain.length || d != "~" + domain && d.lastIndexOf("." + d
omain) != d.length - domain.length - 1)); | 576 let domains = match[1].toUpperCase().split(",").filter(d => d != domain &&
(d.length <= domain.length || d != "~" + domain && d.lastIndexOf("." + domain)
!= d.length - domain.length - 1)); |
577 domains.push("~" + domain); | 577 domains.push("~" + domain); |
578 text = domains.join(",").toLowerCase() + selector; | 578 text = domains.join(",").toLowerCase() + selector; |
579 } | 579 } |
580 else | 580 else |
581 text = "~" + domain.toLowerCase() + text; | 581 text = "~" + domain.toLowerCase() + text; |
582 } | 582 } |
583 | 583 |
584 if (text == filter.text) | 584 if (text == filter.text) |
585 return; // Just in case, shouldn't happen | 585 return; // Just in case, shouldn't happen |
586 | 586 |
587 // Insert new filter before the old one and remove the old one then | 587 // Insert new filter before the old one and remove the old one then |
588 let newFilter = Filter.fromText(text); | 588 let newFilter = Filter.fromText(text); |
589 if (newFilter.disabled && newFilter.subscriptions.length) | 589 if (newFilter.disabled && newFilter.subscriptions.length) |
590 newFilter.disabled = false; | 590 newFilter.disabled = false; |
591 else if (!newFilter.subscriptions.length) | 591 else if (!newFilter.subscriptions.length) |
592 { | 592 { |
593 newFilter.disabled = false; | 593 newFilter.disabled = false; |
594 let subscription = filter.subscriptions.filter(function(s) s instanceof Spec
ialSubscription)[0]; | 594 let subscription = filter.subscriptions.filter(s => s instanceof SpecialSubs
cription)[0]; |
595 if (subscription) | 595 if (subscription) |
596 FilterStorage.addFilter(newFilter, subscription, subscription.filters.inde
xOf(filter)); | 596 FilterStorage.addFilter(newFilter, subscription, subscription.filters.inde
xOf(filter)); |
597 } | 597 } |
598 FilterStorage.removeFilter(filter); | 598 FilterStorage.removeFilter(filter); |
599 | 599 |
600 // Update display | 600 // Update display |
601 for (let i = 0; i < treeView.allData.length; i++) | 601 for (let i = 0; i < treeView.allData.length; i++) |
602 if (treeView.allData[i].filter == filter) | 602 if (treeView.allData[i].filter == filter) |
603 treeView.allData[i].filter = null; | 603 treeView.allData[i].filter = null; |
604 treeView.boxObject.invalidate(); | 604 treeView.boxObject.invalidate(); |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
742 else if (item1.thirdParty && !item2.thirdParty) | 742 else if (item1.thirdParty && !item2.thirdParty) |
743 return -1; | 743 return -1; |
744 else if (!item1.thirdParty && item2.thirdParty) | 744 else if (!item1.thirdParty && item2.thirdParty) |
745 return 1; | 745 return 1; |
746 else | 746 else |
747 return 0; | 747 return 0; |
748 } | 748 } |
749 | 749 |
750 function compareFilterSource(item1, item2) | 750 function compareFilterSource(item1, item2) |
751 { | 751 { |
752 let subs1 = item1.filter ? item1.filter.subscriptions.map(function(s) s.title)
.join(", ") : ""; | 752 let subs1 = item1.filter ? item1.filter.subscriptions.map(s => s.title).join("
, ") : ""; |
753 let subs2 = item2.filter ? item2.filter.subscriptions.map(function(s) s.title)
.join(", ") : ""; | 753 let subs2 = item2.filter ? item2.filter.subscriptions.map(s => s.title).join("
, ") : ""; |
754 if (subs1 < subs2) | 754 if (subs1 < subs2) |
755 return -1; | 755 return -1; |
756 else if (subs1 > subs2) | 756 else if (subs1 > subs2) |
757 return 1; | 757 return 1; |
758 else | 758 else |
759 return 0; | 759 return 0; |
760 } | 760 } |
761 | 761 |
762 function createSortWithFallback(cmpFunc, fallbackFunc, desc) { | 762 function createSortWithFallback(cmpFunc, fallbackFunc, desc) { |
763 var factor = (desc ? -1 : 1); | 763 var factor = (desc ? -1 : 1); |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
873 let size = getItemSize(this.data[row]); | 873 let size = getItemSize(this.data[row]); |
874 return (size ? size.join(" x ") : ""); | 874 return (size ? size.join(" x ") : ""); |
875 } | 875 } |
876 else if (col == "docDomain") | 876 else if (col == "docDomain") |
877 return this.data[row].docDomain + " " + (this.data[row].thirdParty ? doc
DomainThirdParty : docDomainFirstParty); | 877 return this.data[row].docDomain + " " + (this.data[row].thirdParty ? doc
DomainThirdParty : docDomainFirstParty); |
878 else if (col == "filterSource") | 878 else if (col == "filterSource") |
879 { | 879 { |
880 if (!this.data[row].filter) | 880 if (!this.data[row].filter) |
881 return ""; | 881 return ""; |
882 | 882 |
883 return this.data[row].filter.subscriptions.filter(function(s) !s.disable
d).map(function(s) s.title).join(", "); | 883 return this.data[row].filter.subscriptions.filter(s => !s.disabled).map(
s => s.title).join(", "); |
884 } | 884 } |
885 else | 885 else |
886 return this.data[row].location; | 886 return this.data[row].location; |
887 } | 887 } |
888 else { | 888 else { |
889 // Empty list, show dummy | 889 // Empty list, show dummy |
890 if (row > 0 || (col != "address" && col != "filter")) | 890 if (row > 0 || (col != "address" && col != "filter")) |
891 return ""; | 891 return ""; |
892 if (col == "filter") { | 892 if (col == "filter") { |
893 var filter = Policy.isWindowWhitelisted(window.content); | 893 var filter = Policy.isWindowWhitelisted(window.content); |
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1262 return {tooltip: this.itemsDummyTooltip}; | 1262 return {tooltip: this.itemsDummyTooltip}; |
1263 }, | 1263 }, |
1264 | 1264 |
1265 invalidateItem: function(item) | 1265 invalidateItem: function(item) |
1266 { | 1266 { |
1267 let row = this.data.indexOf(item); | 1267 let row = this.data.indexOf(item); |
1268 if (row >= 0) | 1268 if (row >= 0) |
1269 this.boxObject.invalidateRow(row); | 1269 this.boxObject.invalidateRow(row); |
1270 } | 1270 } |
1271 } | 1271 } |
OLD | NEW |