Index: popup.js |
diff --git a/popup.js b/popup.js |
index d611a7b44aa3bfd718e15635d0ec99297413008e..20a62d1e64fb14cddda18028c21b5e33952a5ba9 100644 |
--- a/popup.js |
+++ b/popup.js |
@@ -15,20 +15,22 @@ |
* along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
*/ |
-var backgroundPage = ext.backgroundPage.getWindow(); |
-var require = backgroundPage.require; |
+"use strict"; |
-var Filter = require("filterClasses").Filter; |
-var FilterStorage = require("filterStorage").FilterStorage; |
-var Prefs = require("prefs").Prefs; |
-var checkWhitelisted = require("whitelisting").checkWhitelisted; |
-var getDecodedHostname = require("url").getDecodedHostname; |
+const backgroundPage = ext.backgroundPage.getWindow(); |
+const {require} = backgroundPage; |
Sebastian Noack
2017/01/18 11:24:29
Note that backgroundPage isn't used anywhere else,
kzar
2017/01/18 11:46:40
Done.
|
-var page = null; |
+const {Filter} = require("filterClasses"); |
+const {FilterStorage} = require("filterStorage"); |
+const {Prefs} = require("prefs"); |
+const {checkWhitelisted} = require("whitelisting"); |
+const {getDecodedHostname} = require("url"); |
+ |
+let page = null; |
function onLoad() |
{ |
- ext.pages.query({active: true, lastFocusedWindow: true}, function(pages) |
+ ext.pages.query({active: true, lastFocusedWindow: true}, pages => |
{ |
page = pages[0]; |
@@ -40,7 +42,7 @@ function onLoad() |
{ |
document.body.classList.add("nohtml"); |
require("messaging").getPort(window).on( |
- "composer.ready", function(message, sender) |
+ "composer.ready", (message, sender) => |
{ |
if (sender.page.id == page.id) |
document.body.classList.remove("nohtml"); |
@@ -57,7 +59,7 @@ function onLoad() |
if (checkWhitelisted(page)) |
document.body.classList.add("disabled"); |
- page.sendMessage({type: "composer.content.getState"}, function(response) |
+ page.sendMessage({type: "composer.content.getState"}, response => |
{ |
if (response && response.active) |
document.body.classList.add("clickhide-active"); |
@@ -68,16 +70,14 @@ function onLoad() |
document.getElementById("enabled").addEventListener("click", toggleEnabled, false); |
document.getElementById("clickhide").addEventListener("click", activateClickHide, false); |
document.getElementById("clickhide-cancel").addEventListener("click", cancelClickHide, false); |
- document.getElementById("options").addEventListener("click", function() |
+ document.getElementById("options").addEventListener("click", () => |
{ |
ext.showOptions(); |
}, false); |
// Set up collapsing of menu items |
- var collapsers = document.getElementsByClassName("collapse"); |
- for (var i = 0; i < collapsers.length; i++) |
+ for (let collapser of document.getElementsByClassName("collapse")) |
{ |
- var collapser = collapsers[i]; |
collapser.addEventListener("click", toggleCollapse, false); |
if (!Prefs[collapser.dataset.option]) |
document.getElementById(collapser.dataset.collapsable).classList.add("collapsed"); |
@@ -86,11 +86,11 @@ function onLoad() |
function toggleEnabled() |
{ |
- var disabled = document.body.classList.toggle("disabled"); |
+ let disabled = document.body.classList.toggle("disabled"); |
if (disabled) |
{ |
- var host = getDecodedHostname(page.url).replace(/^www\./, ""); |
- var filter = Filter.fromText("@@||" + host + "^$document"); |
+ let host = getDecodedHostname(page.url).replace(/^www\./, ""); |
+ let filter = Filter.fromText("@@||" + host + "^$document"); |
if (filter.subscriptions.length && filter.disabled) |
filter.disabled = false; |
else |
@@ -102,7 +102,7 @@ function toggleEnabled() |
else |
{ |
// Remove any exception rules applying to this URL |
- var filter = checkWhitelisted(page); |
+ let filter = checkWhitelisted(page); |
while (filter) |
{ |
FilterStorage.removeFilter(filter); |
@@ -135,7 +135,7 @@ function cancelClickHide() |
function toggleCollapse(event) |
{ |
- var collapser = event.currentTarget; |
+ let collapser = event.currentTarget; |
Prefs[collapser.dataset.option] = !Prefs[collapser.dataset.option]; |
collapser.parentNode.classList.toggle("collapsed"); |
} |