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,24 +32,28 @@ function arrange() {
function events() { function events() {
windowman.events(); windowman.events();
document if (document.querySelector(`[data-action="filters,update"]`)) {
.querySelector(`[data-action="filters,update"]`) document
.addEventListener(`click`, async () => { .querySelector(`[data-action="filters,update"]`)
let filters = await import(chrome.runtime.getURL(`scripts/filters.js`)); .addEventListener(`click`, async () => {
filters.update(); let filters = await import(chrome.runtime.getURL(`scripts/filters.js`));
}); filters.update();
document });
.querySelector(`[data-action="storage,clear"]`) }
.addEventListener(`click`, async () => { if (document.querySelector(`[data-action="storage,clear"]`)) {
let storage = await import( document
chrome.runtime.getURL(`scripts/secretariat.js`) .querySelector(`[data-action="storage,clear"]`)
); .addEventListener(`click`, async () => {
storage.forget(`sites`); let storage = await import(
}); chrome.runtime.getURL(`scripts/secretariat.js`)
);
storage.forget(`sites`);
});
}
} }
function main() { function main() {
let tab = windowman.prepare(); windowman.prepare();
windowman.fill(); windowman.fill();
events(); events();
arrange(); arrange();