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 /** @module filterComposer */ | 18 /** @module filterComposer */ |
19 | 19 |
20 "use strict"; | 20 "use strict"; |
21 | 21 |
22 const {defaultMatcher} = require("../adblockpluscore/lib/matcher"); | 22 const {defaultMatcher} = require("../adblockpluscore/lib/matcher"); |
23 const {RegExpFilter} = require("../adblockpluscore/lib/filterClasses"); | 23 const {RegExpFilter} = require("../adblockpluscore/lib/filterClasses"); |
24 const {FilterNotifier} = require("../adblockpluscore/lib/filterNotifier"); | 24 const {filterNotifier} = require("../adblockpluscore/lib/filterNotifier"); |
25 const {Prefs} = require("./prefs"); | 25 const {Prefs} = require("./prefs"); |
26 const {extractHostFromFrame, isThirdParty} = require("./url"); | 26 const {extractHostFromFrame, isThirdParty} = require("./url"); |
27 const {getKey, checkWhitelisted} = require("./whitelisting"); | 27 const {getKey, checkWhitelisted} = require("./whitelisting"); |
28 const {port} = require("./messaging"); | 28 const {port} = require("./messaging"); |
29 const info = require("info"); | 29 const info = require("info"); |
30 | 30 |
31 let readyPages = new ext.PageMap(); | 31 let readyPages = new ext.PageMap(); |
32 | 32 |
33 /** | 33 /** |
34 * Checks whether the given page is ready to use the filter composer | 34 * Checks whether the given page is ready to use the filter composer |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 | 182 |
183 // We don't support the filter composer on Firefox for Android, because the | 183 // We don't support the filter composer on Firefox for Android, because the |
184 // user experience on mobile is quite different. | 184 // user experience on mobile is quite different. |
185 if (info.application != "fennec" && | 185 if (info.application != "fennec" && |
186 !filter && Prefs.shouldShowBlockElementMenu && readyPages.has(page)) | 186 !filter && Prefs.shouldShowBlockElementMenu && readyPages.has(page)) |
187 { | 187 { |
188 page.contextMenus.create(contextMenuItem); | 188 page.contextMenus.create(contextMenuItem); |
189 } | 189 } |
190 } | 190 } |
191 | 191 |
192 FilterNotifier.on("page.WhitelistingStateRevalidate", updateContextMenu); | 192 filterNotifier.on("page.WhitelistingStateRevalidate", updateContextMenu); |
193 | 193 |
194 Prefs.on("shouldShowBlockElementMenu", () => | 194 Prefs.on("shouldShowBlockElementMenu", () => |
195 { | 195 { |
196 browser.tabs.query({}, tabs => | 196 browser.tabs.query({}, tabs => |
197 { | 197 { |
198 for (let tab of tabs) | 198 for (let tab of tabs) |
199 updateContextMenu(new ext.Page(tab)); | 199 updateContextMenu(new ext.Page(tab)); |
200 }); | 200 }); |
201 }); | 201 }); |
202 | 202 |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
331 // When tabs start loading we send them a message to ensure that the state | 331 // When tabs start loading we send them a message to ensure that the state |
332 // of the "block element" tool is reset. This is necessary since Firefox will | 332 // of the "block element" tool is reset. This is necessary since Firefox will |
333 // sometimes cache the state of a tab when the user navigates back / forward, | 333 // sometimes cache the state of a tab when the user navigates back / forward, |
334 // which includes the state of the "block element" tool. | 334 // which includes the state of the "block element" tool. |
335 // Since sending this message will often fail (e.g. for new tabs which have | 335 // Since sending this message will often fail (e.g. for new tabs which have |
336 // just been opened) we catch and ignore any exception thrown. | 336 // just been opened) we catch and ignore any exception thrown. |
337 browser.tabs.sendMessage( | 337 browser.tabs.sendMessage( |
338 page.id, {type: "composer.content.finished"} | 338 page.id, {type: "composer.content.finished"} |
339 ).catch(() => {}); | 339 ).catch(() => {}); |
340 }); | 340 }); |
OLD | NEW |