| Left: | ||
| Right: |
| OLD | NEW |
|---|---|
| (Empty) | |
| 1 /* | |
| 2 * This file is part of Adblock Plus <https://adblockplus.org/>, | |
| 3 * Copyright (C) 2006-present eyeo GmbH | |
| 4 * | |
| 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 | |
| 7 * published by the Free Software Foundation. | |
| 8 * | |
| 9 * Adblock Plus is distributed in the hope that it will be useful, | |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 12 * GNU General Public License for more details. | |
| 13 * | |
| 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/>. | |
| 16 */ | |
| 17 | |
| 18 /** @module browserAction */ | |
| 19 | |
| 20 "use strict"; | |
| 21 | |
| 22 const {getDecodedHostname} = require("url"); | |
| 23 const {checkWhitelisted} = require("whitelisting"); | |
| 24 | |
| 25 // On Firefox for Android, open the options page directly when the browser | |
| 26 // action is clicked. | |
| 27 chrome.browserAction.onClicked.addListener(() => | |
|
Manish Jethani
2017/09/07 11:04:16
Note: We don't have to check for "fennec" here, be
| |
| 28 { | |
| 29 ext.pages.query({active: true, lastFocusedWindow: true}, pages => | |
| 30 { | |
| 31 let currentPage = pages[0]; | |
| 32 | |
| 33 ext.showOptions(optionsPage => | |
| 34 { | |
| 35 if (!["http:", "https:"].includes(currentPage.url.protocol)) | |
|
Manish Jethani
2017/09/07 11:04:16
Now checking specifically for HTTP and HTTPS.
Sebastian Noack
2017/09/07 16:36:45
It would be great if we could reuse the same code
Manish Jethani
2017/09/08 10:02:24
From what I can tell the code here is nearly ident
Sebastian Noack
2017/09/11 22:40:02
What I meant was to avoid duplicating the logic he
| |
| 36 return; | |
| 37 | |
| 38 optionsPage.sendMessage({ | |
| 39 type: "app.respond", | |
| 40 action: "showPageOptions", | |
| 41 args: [ | |
| 42 { | |
| 43 host: getDecodedHostname(currentPage.url).replace(/^www\./, ""), | |
|
Manish Jethani
2017/09/07 11:04:16
Using getDecodedHostname here so we can handle Uni
| |
| 44 whitelisted: checkWhitelisted(currentPage) | |
| 45 } | |
| 46 ] | |
| 47 }); | |
| 48 }); | |
| 49 }); | |
| 50 }); | |
| OLD | NEW |