updated settings

This commit is contained in:
buzzcode2007 2024-04-02 17:15:35 +08:00
parent a980db5b11
commit e53cef75b6

View file

@ -1,82 +1,97 @@
/* Settings.js /* Settings.js
Build the interface for the settings Build the interface for the settings
*/ */
// Import modules. // Import modules.
//import { windowman } from "../windowman.js"; //import { windowman } from "../windowman.js";
async function build() { async function build() {
let secretariat = ( let secretariat = (
await import(chrome.runtime.getURL("scripts/secretariat.js")) await import(chrome.runtime.getURL("scripts/secretariat.js"))
).secretariat; );
let windowman = ( let windowman = (
await import(chrome.runtime.getURL("gui/scripts/windowman.js")) await import(chrome.runtime.getURL("gui/scripts/windowman.js"))
).windowman; ).default;
let window = new windowman(); let window = new windowman();
} }
/* /*
Arrange the interface. Arrange the interface.
*/ */
/*function arrange() { /*function arrange() {
async function openLast() { async function openLast() {
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 || typeof last_opened !== `number`) { if (!last_opened || typeof last_opened !== `number`) {
last_opened = 0; last_opened = 0;
} }
if (document.querySelector(`[role="tab"][tab="${last_opened}"]`)) { if (document.querySelector(`[role="tab"][tab="${last_opened}"]`)) {
document.querySelector(`[role="tab"][tab="${last_opened}"]`).click(); document.querySelector(`[role="tab"][tab="${last_opened}"]`).click();
} }
} }
openLast(); openLast();
} }
function main() { function main() {
windowman.fill(); windowman.fill();
events(); events();
arrange(); arrange();
}*/ }*/
/* /*
Define the mapping of each button. Define the mapping of each button.
*/ */
function events() { function events() {
if (document.querySelector(`[data-action="filters,update"]`)) { if (document.querySelector(`[data-action="filters,update"]`)) {
document document.querySelector(`[data-action="filters,update"]`).addEventListener(`click`, async () => {
.querySelector(`[data-action="filters,update"]`) let filters = new ((
.addEventListener(`click`, async () => { await import(chrome.runtime.getURL(`scripts/filters.js`))
let filters = ( ).default);
await import(chrome.runtime.getURL(`scripts/filters.js`)) await filters.update();
).default; });
filters.update(); }
});
} if (document.querySelector(`[data-action="filters,add,one"]`)) {
if (document.querySelector(`[data-action="storage,clear"]`)) { document.querySelector(`[data-action="filters,add,one"]`).addEventListener(`click`, async () => {
document (async () => {
.querySelector(`[data-action="storage,clear"]`) // Import the filters module.
.addEventListener(`click`, async () => { let texts = (await import(chrome.runtime.getURL(`gui/scripts/read.js`))).default;
let storage = ( let filters = new ((await import(chrome.runtime.getURL(`scripts/filters.js`))).default);
await import(chrome.runtime.getURL(`scripts/secretariat.js`))
)["secretariat"]; // Open text input window for adding a filter.
storage.forget(`sites`); let filter_source = prompt(texts.localized(`settings_filters_add_prompt`));
}); if (filter_source.trim) {
} filters.update(filter_source.trim);
};
})();
});
}
if (document.querySelector(`[data-action="storage,clear"]`)) {
document
.querySelector(`[data-action="storage,clear"]`)
.addEventListener(`click`, async () => {
let storage = (
await import(chrome.runtime.getURL(`scripts/secretariat.js`))
)["secretariat"];
storage.forget(`sites`);
});
}
} }
//main(); //main();
function load() { function load() {
document.addEventListener("DOMContentLoaded", function () { document.addEventListener("DOMContentLoaded", function () {
M.AutoInit(); M.AutoInit();
}); events();
});
build(); build();
events();
} }
load(); load();