LEFT | RIGHT |
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-present eyeo GmbH | 3 * Copyright (C) 2006-present 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 /** | 20 /** |
21 * @fileOverview Definition of Filter class and its subclasses. | 21 * @fileOverview Definition of Filter class and its subclasses. |
22 */ | 22 */ |
23 | 23 |
24 const {extend} = require("./coreUtils"); | 24 const {extend} = require("./coreUtils"); |
25 const {filterToRegExp} = require("./common"); | 25 const {filterToRegExp} = require("./common"); |
26 const {normalizeHostname, suffixes} = require("./domain"); | 26 const {normalizeHostname, domainSuffixes} = require("./url"); |
27 const {filterNotifier} = require("./filterNotifier"); | 27 const {filterNotifier} = require("./filterNotifier"); |
28 | 28 |
29 const resources = require("../data/resources.json"); | 29 const resources = require("../data/resources.json"); |
30 | 30 |
31 /** | 31 /** |
32 * Map of internal resources for URL rewriting. | 32 * Map of internal resources for URL rewriting. |
33 * @type {Map.<string,string>} | 33 * @type {Map.<string,string>} |
34 */ | 34 */ |
35 let resourceMap = new Map( | 35 let resourceMap = new Map( |
36 Object.keys(resources).map(key => [key, resources[key]]) | 36 Object.keys(resources).map(key => [key, resources[key]]) |
(...skipping 562 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
599 | 599 |
600 // If no domains are set the rule matches everywhere | 600 // If no domains are set the rule matches everywhere |
601 if (!domains) | 601 if (!domains) |
602 return true; | 602 return true; |
603 | 603 |
604 // If the document has no host name, match only if the filter | 604 // If the document has no host name, match only if the filter |
605 // isn't restricted to specific domains | 605 // isn't restricted to specific domains |
606 if (!docDomain) | 606 if (!docDomain) |
607 return domains.get(""); | 607 return domains.get(""); |
608 | 608 |
609 for (docDomain of suffixes(normalizeHostname(docDomain))) | 609 for (docDomain of domainSuffixes(normalizeHostname(docDomain))) |
610 { | 610 { |
611 let isDomainIncluded = domains.get(docDomain); | 611 let isDomainIncluded = domains.get(docDomain); |
612 if (typeof isDomainIncluded != "undefined") | 612 if (typeof isDomainIncluded != "undefined") |
613 return isDomainIncluded; | 613 return isDomainIncluded; |
614 } | 614 } |
615 | 615 |
616 return domains.get(""); | 616 return domains.get(""); |
617 }, | 617 }, |
618 | 618 |
619 /** | 619 /** |
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
905 | 905 |
906 if (!this.matchCase) | 906 if (!this.matchCase) |
907 location = lowerCaseLocation || location.toLowerCase(); | 907 location = lowerCaseLocation || location.toLowerCase(); |
908 | 908 |
909 let {pattern} = this; | 909 let {pattern} = this; |
910 | 910 |
911 let startsWithDoubleAnchor = pattern[0] == "|" && pattern[1] == "|"; | 911 let startsWithDoubleAnchor = pattern[0] == "|" && pattern[1] == "|"; |
912 let endsWithSeparator = pattern[pattern.length - 1] == "^"; | 912 let endsWithSeparator = pattern[pattern.length - 1] == "^"; |
913 | 913 |
914 if (startsWithDoubleAnchor) | 914 if (startsWithDoubleAnchor) |
915 pattern = pattern.substring(2); | 915 pattern = pattern.substr(2); |
916 | 916 |
917 if (endsWithSeparator) | 917 if (endsWithSeparator) |
918 pattern = pattern.slice(0, -1); | 918 pattern = pattern.slice(0, -1); |
919 | 919 |
920 let index = location.indexOf(pattern); | 920 let index = location.indexOf(pattern); |
921 | 921 |
922 // The "||" prefix requires that the text that follows does not start | 922 // The "||" prefix requires that the text that follows does not start |
923 // with a forward slash. | 923 // with a forward slash. |
924 return index != -1 && | 924 return index != -1 && |
925 (!startsWithDoubleAnchor || location[index] != "/" && | 925 (!startsWithDoubleAnchor || location[index] != "/" && |
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1437 | 1437 |
1438 /** | 1438 /** |
1439 * Script that should be executed | 1439 * Script that should be executed |
1440 * @type {string} | 1440 * @type {string} |
1441 */ | 1441 */ |
1442 get script() | 1442 get script() |
1443 { | 1443 { |
1444 return this.body; | 1444 return this.body; |
1445 } | 1445 } |
1446 }); | 1446 }); |
LEFT | RIGHT |