Remember last active tab when opening the option window.

This commit is contained in:
hackademix 2022-03-12 22:54:01 +01:00
parent ca2d95daaa
commit 25c8123513
3 changed files with 2 additions and 43 deletions

View File

@ -1,41 +0,0 @@
/*
* NoScript - a Firefox extension for whitelist driven safe JavaScript execution
*
* Copyright (C) 2005-2021 Giorgio Maone <https://maone.net>
*
* 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 <https://www.gnu.org/licenses/>.
*/
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(";");
});
}
}
}

@ -1 +1 @@
Subproject commit 74ffe5f583fe952d1114ae08665bfcaa132eb280 Subproject commit 8e753c290fcde4673a5ca2b4a2e5960f551c0e18

View File

@ -156,7 +156,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
</div> </div>
</div> </div>
<script src="/lib/persistent-tabs.js"></script> <script src="/nscl/service/persistent-tabs.js"></script>
<script src="options.js"></script> <script src="options.js"></script>
</body> </body>
</html> </html>