| 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 "use strict"; | 18 "use strict"; |
| 19 | 19 |
| 20 const {require} = ext.backgroundPage.getWindow(); | 20 const {require} = ext.backgroundPage.getWindow(); |
| 21 | 21 |
| 22 const {Filter} = require("filterClasses"); | 22 const {Filter} = require("filterClasses"); |
| 23 const {FilterStorage} = require("filterStorage"); | 23 const {FilterStorage} = require("filterStorage"); |
| 24 const {Prefs} = require("prefs"); | |
| 25 const {checkWhitelisted} = require("whitelisting"); | 24 const {checkWhitelisted} = require("whitelisting"); |
| 26 const {getDecodedHostname} = require("url"); | 25 const {getDecodedHostname} = require("url"); |
| 27 | 26 |
| 28 let page = null; | 27 let page = null; |
| 29 | 28 |
| 30 function onLoad() | 29 function onLoad() |
| 31 { | 30 { |
| 32 ext.pages.query({active: true, lastFocusedWindow: true}, pages => | 31 ext.pages.query({active: true, lastFocusedWindow: true}, pages => |
| 33 { | 32 { |
| 34 page = pages[0]; | 33 page = pages[0]; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 ); | 76 ); |
| 78 document.getElementById("options").addEventListener("click", () => | 77 document.getElementById("options").addEventListener("click", () => |
| 79 { | 78 { |
| 80 ext.showOptions(); | 79 ext.showOptions(); |
| 81 }, false); | 80 }, false); |
| 82 | 81 |
| 83 // Set up collapsing of menu items | 82 // Set up collapsing of menu items |
| 84 for (let collapser of document.getElementsByClassName("collapse")) | 83 for (let collapser of document.getElementsByClassName("collapse")) |
| 85 { | 84 { |
| 86 collapser.addEventListener("click", toggleCollapse, false); | 85 collapser.addEventListener("click", toggleCollapse, false); |
| 87 if (!Prefs[collapser.dataset.option]) | 86 ext.prefs.get(collapser.dataset.option, value => |
| 88 { | 87 { |
| 89 document.getElementById( | 88 if (value) |
| 90 collapser.dataset.collapsable | 89 { |
| 91 ).classList.add("collapsed"); | 90 document.getElementById( |
| 92 } | 91 collapser.dataset.collapsible |
| 92 ).classList.remove("collapsed"); |
| 93 } |
| 94 }); |
| 93 } | 95 } |
| 94 } | 96 } |
| 95 | 97 |
| 96 function toggleEnabled() | 98 function toggleEnabled() |
| 97 { | 99 { |
| 98 let disabled = document.body.classList.toggle("disabled"); | 100 let disabled = document.body.classList.toggle("disabled"); |
| 99 if (disabled) | 101 if (disabled) |
| 100 { | 102 { |
| 101 let host = getDecodedHostname(page.url).replace(/^www\./, ""); | 103 let host = getDecodedHostname(page.url).replace(/^www\./, ""); |
| 102 let filter = Filter.fromText("@@||" + host + "^$document"); | 104 let filter = Filter.fromText("@@||" + host + "^$document"); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 window.clearTimeout(activateClickHide.timeout); | 140 window.clearTimeout(activateClickHide.timeout); |
| 139 activateClickHide.timeout = null; | 141 activateClickHide.timeout = null; |
| 140 } | 142 } |
| 141 document.body.classList.remove("clickhide-active"); | 143 document.body.classList.remove("clickhide-active"); |
| 142 page.sendMessage({type: "composer.content.finished"}); | 144 page.sendMessage({type: "composer.content.finished"}); |
| 143 } | 145 } |
| 144 | 146 |
| 145 function toggleCollapse(event) | 147 function toggleCollapse(event) |
| 146 { | 148 { |
| 147 let collapser = event.currentTarget; | 149 let collapser = event.currentTarget; |
| 148 Prefs[collapser.dataset.option] = !Prefs[collapser.dataset.option]; | 150 let collapsible = document.getElementById(collapser.dataset.collapsible); |
| 149 collapser.parentNode.classList.toggle("collapsed"); | 151 collapsible.classList.toggle("collapsed"); |
| 152 ext.prefs.toggle(collapser.dataset.option); |
| 150 } | 153 } |
| 151 | 154 |
| 152 document.addEventListener("DOMContentLoaded", onLoad, false); | 155 document.addEventListener("DOMContentLoaded", onLoad, false); |
| OLD | NEW |