| 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("matcher"); | 22 const {defaultMatcher} = require("matcher"); |
| 23 const {RegExpFilter} = require("filterClasses"); | 23 const {RegExpFilter} = require("filterClasses"); |
| 24 const {FilterNotifier} = require("filterNotifier"); | 24 const {FilterNotifier} = require("filterNotifier"); |
| 25 const {Prefs} = require("prefs"); | 25 const {Prefs} = require("prefs"); |
| 26 const {extractHostFromFrame, stringifyURL, isThirdParty} = require("url"); | 26 const {extractHostFromFrame, stringifyURL, 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 | 30 |
| 30 let readyPages = new ext.PageMap(); | 31 let readyPages = new ext.PageMap(); |
| 31 | 32 |
| 32 /** | 33 /** |
| 33 * 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 |
| 34 * | 35 * |
| 35 * @param {Page} page | 36 * @param {Page} page |
| 36 * @return {boolean} | 37 * @return {boolean} |
| 37 */ | 38 */ |
| 38 exports.isPageReady = page => | 39 exports.isPageReady = page => |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 page.sendMessage({type: "composer.content.contextMenuClicked"}); | 174 page.sendMessage({type: "composer.content.contextMenuClicked"}); |
| 174 } | 175 } |
| 175 }; | 176 }; |
| 176 | 177 |
| 177 function updateContextMenu(page, filter) | 178 function updateContextMenu(page, filter) |
| 178 { | 179 { |
| 179 page.contextMenus.remove(contextMenuItem); | 180 page.contextMenus.remove(contextMenuItem); |
| 180 | 181 |
| 181 if (typeof filter == "undefined") | 182 if (typeof filter == "undefined") |
| 182 filter = checkWhitelisted(page); | 183 filter = checkWhitelisted(page); |
| 183 if (!filter && Prefs.shouldShowBlockElementMenu && readyPages.has(page)) | 184 |
| 185 // We don't support the filter composer on Firefox for Android, because the |
| 186 // user experience on mobile is quite different. |
| 187 if (info.application != "fennec" && |
| 188 !filter && Prefs.shouldShowBlockElementMenu && readyPages.has(page)) |
| 189 { |
| 184 page.contextMenus.create(contextMenuItem); | 190 page.contextMenus.create(contextMenuItem); |
| 191 } |
| 185 } | 192 } |
| 186 | 193 |
| 187 FilterNotifier.on("page.WhitelistingStateRevalidate", updateContextMenu); | 194 FilterNotifier.on("page.WhitelistingStateRevalidate", updateContextMenu); |
| 188 | 195 |
| 189 Prefs.on("shouldShowBlockElementMenu", () => | 196 Prefs.on("shouldShowBlockElementMenu", () => |
| 190 { | 197 { |
| 191 ext.pages.query({}, pages => | 198 ext.pages.query({}, pages => |
| 192 { | 199 { |
| 193 for (let page of pages) | 200 for (let page of pages) |
| 194 updateContextMenu(page); | 201 updateContextMenu(page); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 | 258 |
| 252 port.on("composer.quoteCSS", (message, sender) => | 259 port.on("composer.quoteCSS", (message, sender) => |
| 253 { | 260 { |
| 254 return quoteCSS(message.CSS); | 261 return quoteCSS(message.CSS); |
| 255 }); | 262 }); |
| 256 | 263 |
| 257 ext.pages.onLoading.addListener(page => | 264 ext.pages.onLoading.addListener(page => |
| 258 { | 265 { |
| 259 page.sendMessage({type: "composer.content.finished"}); | 266 page.sendMessage({type: "composer.content.finished"}); |
| 260 }); | 267 }); |
| OLD | NEW |