updated settings

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

View file

@ -8,10 +8,10 @@
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();
} }
@ -48,15 +48,30 @@ function main() {
*/ */
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 () => {
let filters = (
await import(chrome.runtime.getURL(`scripts/filters.js`)) await import(chrome.runtime.getURL(`scripts/filters.js`))
).default; ).default);
filters.update(); await filters.update();
}); });
} }
if (document.querySelector(`[data-action="filters,add,one"]`)) {
document.querySelector(`[data-action="filters,add,one"]`).addEventListener(`click`, async () => {
(async () => {
// Import the filters module.
let texts = (await import(chrome.runtime.getURL(`gui/scripts/read.js`))).default;
let filters = new ((await import(chrome.runtime.getURL(`scripts/filters.js`))).default);
// Open text input window for adding a filter.
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"]`)) { if (document.querySelector(`[data-action="storage,clear"]`)) {
document document
.querySelector(`[data-action="storage,clear"]`) .querySelector(`[data-action="storage,clear"]`)
@ -73,10 +88,10 @@ function events() {
function load() { function load() {
document.addEventListener("DOMContentLoaded", function () { document.addEventListener("DOMContentLoaded", function () {
M.AutoInit(); M.AutoInit();
events();
}); });
build(); build();
events();
} }
load(); load();