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-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 {filterNotifier} = require("./filterNotifier"); | |
25 const {extend} = require("./coreUtils"); | 24 const {extend} = require("./coreUtils"); |
26 const {filterToRegExp} = require("./common"); | 25 const {filterToRegExp} = require("./common"); |
| 26 const {suffixes} = require("./domain"); |
| 27 const {filterNotifier} = require("./filterNotifier"); |
| 28 |
27 const resources = require("../data/resources.json"); | 29 const resources = require("../data/resources.json"); |
28 | 30 |
29 /** | 31 /** |
30 * Map of internal resources for URL rewriting. | 32 * Map of internal resources for URL rewriting. |
31 * @type {Map.<string,string>} | 33 * @type {Map.<string,string>} |
32 */ | 34 */ |
33 let resourceMap = new Map( | 35 let resourceMap = new Map( |
34 Object.keys(resources).map(key => [key, resources[key]]) | 36 Object.keys(resources).map(key => [key, resources[key]]) |
35 ); | 37 ); |
36 | 38 |
(...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
602 // 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 |
603 // isn't restricted to specific domains | 605 // isn't restricted to specific domains |
604 if (!docDomain) | 606 if (!docDomain) |
605 return domains.get(""); | 607 return domains.get(""); |
606 | 608 |
607 if (docDomain[docDomain.length - 1] == ".") | 609 if (docDomain[docDomain.length - 1] == ".") |
608 docDomain = docDomain.replace(/\.+$/, ""); | 610 docDomain = docDomain.replace(/\.+$/, ""); |
609 | 611 |
610 docDomain = docDomain.toLowerCase(); | 612 docDomain = docDomain.toLowerCase(); |
611 | 613 |
612 while (true) | 614 for (docDomain of suffixes(docDomain)) |
613 { | 615 { |
614 let isDomainIncluded = domains.get(docDomain); | 616 let isDomainIncluded = domains.get(docDomain); |
615 if (typeof isDomainIncluded != "undefined") | 617 if (typeof isDomainIncluded != "undefined") |
616 return isDomainIncluded; | 618 return isDomainIncluded; |
| 619 } |
617 | 620 |
618 let nextDot = docDomain.indexOf("."); | |
619 if (nextDot < 0) | |
620 break; | |
621 docDomain = docDomain.substr(nextDot + 1); | |
622 } | |
623 return domains.get(""); | 621 return domains.get(""); |
624 }, | 622 }, |
625 | 623 |
626 /** | 624 /** |
627 * Checks whether this filter is active only on a domain and its subdomains. | 625 * Checks whether this filter is active only on a domain and its subdomains. |
628 * @param {string} docDomain | 626 * @param {string} docDomain |
629 * @return {boolean} | 627 * @return {boolean} |
630 */ | 628 */ |
631 isActiveOnlyOnDomain(docDomain) | 629 isActiveOnlyOnDomain(docDomain) |
632 { | 630 { |
(...skipping 803 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1436 | 1434 |
1437 /** | 1435 /** |
1438 * Script that should be executed | 1436 * Script that should be executed |
1439 * @type {string} | 1437 * @type {string} |
1440 */ | 1438 */ |
1441 get script() | 1439 get script() |
1442 { | 1440 { |
1443 return this.body; | 1441 return this.body; |
1444 } | 1442 } |
1445 }); | 1443 }); |
OLD | NEW |