From 25c81235133cb988193fd88accc8afb04b9d7673 Mon Sep 17 00:00:00 2001 From: hackademix Date: Sat, 12 Mar 2022 22:54:01 +0100 Subject: [PATCH] Remember last active tab when opening the option window. --- src/lib/persistent-tabs.js | 41 -------------------------------------- src/nscl | 2 +- src/ui/options.html | 2 +- 3 files changed, 2 insertions(+), 43 deletions(-) delete mode 100644 src/lib/persistent-tabs.js diff --git a/src/lib/persistent-tabs.js b/src/lib/persistent-tabs.js deleted file mode 100644 index a9a717b..0000000 --- a/src/lib/persistent-tabs.js +++ /dev/null @@ -1,41 +0,0 @@ -/* - * NoScript - a Firefox extension for whitelist driven safe JavaScript execution - * - * Copyright (C) 2005-2021 Giorgio Maone - * - * SPDX-License-Identifier: GPL-3.0-or-later - * - * This program is free software: you can redistribute it and/or modify it under - * the terms of the GNU General Public License as published by the Free Software - * Foundation, either version 3 of the License, or (at your option) any later - * version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along with - * this program. If not, see . - */ - -if (typeof flextabs === "function") { - - for (let tabs of document.querySelectorAll(".flextabs")) { - flextabs(tabs).init(); - let {id} = tabs; - if (!id) continue; - let rx = new RegExp(`(?:^|[#;])tab-${id}=(\\d+)(?:;|$)`); - let current = location.hash.match(rx); - console.log(`persisted %o`, current); - let toggles = Array.from(tabs.querySelectorAll(".flextabs__toggle")); - let currentToggle = toggles[current && parseInt(current[1]) || 0]; - if (currentToggle) currentToggle.click(); - for (let toggle of toggles) { - toggle.addEventListener("click", e => { - let currentIdx = toggles.indexOf(toggle); - location.hash = location.hash.split(";").filter(p => !rx.test(p)) - .concat(`tab-${id}=${currentIdx}`).join(";"); - }); - } - } -} diff --git a/src/nscl b/src/nscl index 74ffe5f..8e753c2 160000 --- a/src/nscl +++ b/src/nscl @@ -1 +1 @@ -Subproject commit 74ffe5f583fe952d1114ae08665bfcaa132eb280 +Subproject commit 8e753c290fcde4673a5ca2b4a2e5960f551c0e18 diff --git a/src/ui/options.html b/src/ui/options.html index fcf77b9..e19082a 100644 --- a/src/ui/options.html +++ b/src/ui/options.html @@ -156,7 +156,7 @@ SPDX-License-Identifier: GPL-3.0-or-later - +