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

Side by Side Diff: lib/abp2blocklist.js

Issue 29501571: Noissue - Skip unless-domain if list is empty (Closed) Base URL: https://hg.adblockplus.org/abp2blocklist
Patch Set: Created July 31, 2017, 12:34 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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-2017 eyeo GmbH 3 * Copyright (C) 2006-2017 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 624 matching lines...) Expand 10 before | Expand all | Expand 10 after
635 newSelector.push('[id=', selector.substring(pos.start + 1, pos.end), ']'); 635 newSelector.push('[id=', selector.substring(pos.start + 1, pos.end), ']');
636 i = pos.end; 636 i = pos.end;
637 } 637 }
638 newSelector.push(selector.substring(i)); 638 newSelector.push(selector.substring(i));
639 639
640 return newSelector.join(""); 640 return newSelector.join("");
641 } 641 }
642 642
643 function addCSSRules(rules, selectors, domain, exceptionDomains) 643 function addCSSRules(rules, selectors, domain, exceptionDomains)
644 { 644 {
645 let unlessDomain = exceptionDomains.size > 0 ? [] : null; 645 let unlessDomain = [];
646 646
647 exceptionDomains.forEach(name => 647 exceptionDomains.forEach(name =>
648 { 648 {
649 // For domain-specific filters, include the exception domains only if 649 // For domain-specific filters, include the exception domains only if
650 // they're subdomains of the given domain. 650 // they're subdomains of the given domain.
651 if (!domain || name.substr(-domain.length - 1) == "." + domain) 651 if (!domain || name.substr(-domain.length - 1) == "." + domain)
652 unlessDomain.push("*" + name); 652 unlessDomain.push("*" + name);
653 }); 653 });
654 654
655 while (selectors.length) 655 while (selectors.length)
656 { 656 {
657 let selector = selectors.splice(0, selectorLimit).join(", "); 657 let selector = selectors.splice(0, selectorLimit).join(", ");
658 658
659 // As of Safari 9.0 element IDs are matched as lowercase. We work around 659 // As of Safari 9.0 element IDs are matched as lowercase. We work around
660 // this by converting to the attribute format [id="elementID"] 660 // this by converting to the attribute format [id="elementID"]
661 selector = convertIDSelectorsToAttributeSelectors(selector); 661 selector = convertIDSelectorsToAttributeSelectors(selector);
662 662
663 let rule = { 663 let rule = {
664 trigger: {"url-filter": matchDomain(domain), 664 trigger: {"url-filter": matchDomain(domain),
665 "url-filter-is-case-sensitive": true}, 665 "url-filter-is-case-sensitive": true},
666 action: {type: "css-display-none", 666 action: {type: "css-display-none",
667 selector: selector} 667 selector: selector}
668 }; 668 };
669 669
670 if (unlessDomain) 670 if (unlessDomain.length > 0)
671 rule.trigger["unless-domain"] = unlessDomain; 671 rule.trigger["unless-domain"] = unlessDomain;
672 672
673 rules.push(rule); 673 rules.push(rule);
674 } 674 }
675 } 675 }
676 676
677 /** 677 /**
678 * Check if two strings are a close match 678 * Check if two strings are a close match
679 * 679 *
680 * This function returns an edit operation, one of "substitute", "delete", and 680 * This function returns an edit operation, one of "substitute", "delete", and
(...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after
1321 .then(rules => 1321 .then(rules =>
1322 { 1322 {
1323 ruleGroups[index] = rules; 1323 ruleGroups[index] = rules;
1324 return next(); 1324 return next();
1325 }); 1325 });
1326 } 1326 }
1327 1327
1328 return next(); 1328 return next();
1329 }); 1329 });
1330 }; 1330 };
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld