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-2016 Eyeo GmbH | 3 * Copyright (C) 2006-2016 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 var RegExpFilter = require("filterClasses").RegExpFilter; | 18 let RegExpFilter = require("filterClasses").RegExpFilter; |
19 var ElemHide = require("elemHide").ElemHide; | 19 let ElemHide = require("elemHide").ElemHide; |
20 var checkWhitelisted = require("whitelisting").checkWhitelisted; | 20 let checkWhitelisted = require("whitelisting").checkWhitelisted; |
21 var extractHostFromFrame = require("url").extractHostFromFrame; | 21 let extractHostFromFrame = require("url").extractHostFromFrame; |
22 var port = require("messaging").port; | 22 let port = require("messaging").port; |
23 var devtools = require("devtools"); | 23 let devtools = require("devtools"); |
24 | 24 |
25 port.on("get-selectors", function(msg, sender) | 25 port.on("get-selectors", (msg, sender) => |
26 { | 26 { |
27 var selectors; | 27 let selectors; |
28 var trace = devtools && devtools.hasPanel(sender.page); | 28 let trace = devtools && devtools.hasPanel(sender.page); |
29 | 29 |
30 if (!checkWhitelisted(sender.page, sender.frame, | 30 if (!checkWhitelisted(sender.page, sender.frame, |
31 RegExpFilter.typeMap.DOCUMENT | | 31 RegExpFilter.typeMap.DOCUMENT | |
32 RegExpFilter.typeMap.ELEMHIDE)) | 32 RegExpFilter.typeMap.ELEMHIDE)) |
33 { | 33 { |
34 var specificOnly = checkWhitelisted(sender.page, sender.frame, | 34 let specificOnly = checkWhitelisted(sender.page, sender.frame, |
35 RegExpFilter.typeMap.GENERICHIDE); | 35 RegExpFilter.typeMap.GENERICHIDE); |
36 selectors = ElemHide.getSelectorsForDomain( | 36 selectors = ElemHide.getSelectorsForDomain( |
37 extractHostFromFrame(sender.frame), | 37 extractHostFromFrame(sender.frame), |
38 specificOnly ? ElemHide.SPECIFIC_ONLY : ElemHide.ALL_MATCHING | 38 specificOnly ? ElemHide.SPECIFIC_ONLY : ElemHide.ALL_MATCHING |
39 ); | 39 ); |
40 } | 40 } |
41 else | 41 else |
42 { | 42 { |
43 selectors = []; | 43 selectors = []; |
44 } | 44 } |
45 | 45 |
46 return {selectors: selectors, trace: trace}; | 46 return {selectors: selectors, trace: trace}; |
47 }); | 47 }); |
48 | 48 |
49 port.on("forward", function(msg, sender) | 49 port.on("forward", (msg, sender) => |
50 { | 50 { |
51 var targetPage; | 51 let targetPage; |
52 if (msg.targetPageId) | 52 if (msg.targetPageId) |
53 targetPage = ext.getPage(msg.targetPageId); | 53 targetPage = ext.getPage(msg.targetPageId); |
54 else | 54 else |
55 targetPage = sender.page; | 55 targetPage = sender.page; |
56 | 56 |
57 if (targetPage) | 57 if (targetPage) |
58 { | 58 { |
59 msg.payload.sender = sender.page.id; | 59 msg.payload.sender = sender.page.id; |
60 if (msg.expectsResponse) | 60 if (msg.expectsResponse) |
61 return new Promise(targetPage.sendMessage.bind(targetPage, msg.payload)); | 61 return new Promise(targetPage.sendMessage.bind(targetPage, msg.payload)); |
62 targetPage.sendMessage(msg.payload); | 62 targetPage.sendMessage(msg.payload); |
63 } | 63 } |
64 }); | 64 }); |
OLD | NEW |