reusing settings for filters page

This commit is contained in:
buzz-lightsnack-2007 2024-03-29 22:44:12 +08:00
parent e34013b5f8
commit 73aed76519

View file

@ -14,11 +14,13 @@ function arrange() {
let last_opened = ( let last_opened = (
await Promise.all([secretariat.read([`view`, window.location.href], 1)]) await Promise.all([secretariat.read([`view`, window.location.href], 1)])
)[0]; )[0];
if (!last_opened) { if (!last_opened || typeof last_opened !== `number`) {
last_opened = "settings"; last_opened = 0;
} }
document.querySelector(`[role="tab"][for="${last_opened}"]`).click(); if (document.querySelector(`[role="tab"][tab="${last_opened}"]`)) {
document.querySelector(`[role="tab"][tab="${last_opened}"]`).click();
}
} }
openLast(); openLast();
@ -30,12 +32,15 @@ function arrange() {
function events() { function events() {
windowman.events(); windowman.events();
if (document.querySelector(`[data-action="filters,update"]`)) {
document document
.querySelector(`[data-action="filters,update"]`) .querySelector(`[data-action="filters,update"]`)
.addEventListener(`click`, async () => { .addEventListener(`click`, async () => {
let filters = await import(chrome.runtime.getURL(`scripts/filters.js`)); let filters = await import(chrome.runtime.getURL(`scripts/filters.js`));
filters.update(); filters.update();
}); });
}
if (document.querySelector(`[data-action="storage,clear"]`)) {
document document
.querySelector(`[data-action="storage,clear"]`) .querySelector(`[data-action="storage,clear"]`)
.addEventListener(`click`, async () => { .addEventListener(`click`, async () => {
@ -45,9 +50,10 @@ function events() {
storage.forget(`sites`); storage.forget(`sites`);
}); });
} }
}
function main() { function main() {
let tab = windowman.prepare(); windowman.prepare();
windowman.fill(); windowman.fill();
events(); events();
arrange(); arrange();