| 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(() => | 
|  | 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)) | 
|  | 36         return; | 
|  | 37 | 
|  | 38       optionsPage.sendMessage({ | 
|  | 39         type: "app.respond", | 
|  | 40         action: "showPageOptions", | 
|  | 41         args: [ | 
|  | 42           { | 
|  | 43             host: getDecodedHostname(currentPage.url).replace(/^www\./, ""), | 
|  | 44             whitelisted: checkWhitelisted(currentPage) | 
|  | 45           } | 
|  | 46         ] | 
|  | 47       }); | 
|  | 48     }); | 
|  | 49   }); | 
|  | 50 }); | 
| OLD | NEW | 
|---|