rewrite the other events

This commit is contained in:
buzz-lightsnack-2007 2024-05-12 19:55:07 +08:00
parent be0f4334f7
commit 777191a27c

View file

@ -23,21 +23,8 @@ class Page_Settings extends Page {
@param {object} window the window @param {object} window the window
*/ */
events() { events() {
if (document.querySelector(`[data-action="filters,update"]`)) { (document.querySelector(`[data-action="filters,update"]`))
document ? document.querySelector(`[data-action="filters,update"]`).addEventListener(`click`, async () => {
.querySelector(`[data-action="filters,update"]`)
.addEventListener(`click`, async () => {
let filters = new (
await import(chrome.runtime.getURL(`scripts/filters.js`))
).default();
filters.update();
});
}
if (document.querySelector(`[data-action="filters,add,one"]`)) {
document
.querySelector(`[data-action="filters,add,one"]`)
.addEventListener(`click`, async () => {
// Import the filters module. // Import the filters module.
this.data.filters = (this.data.filters) ? this.data.filters : new filters(); this.data.filters = (this.data.filters) ? this.data.filters : new filters();
@ -56,7 +43,7 @@ class Page_Settings extends Page {
// Update the filter if the source is not empty. // Update the filter if the source is not empty.
if (FILTER_SOURCE ? FILTER_SOURCE.trim() : false) { if (FILTER_SOURCE ? FILTER_SOURCE.trim() : false) {
this.data.filters.update(FILTER_SOURCE.trim()); this.data.filters.update(FILTER_SOURCE.trim());
}; };
}) })
: false; : false;
@ -83,7 +70,7 @@ class Page_Settings extends Page {
} }
}); });
} }
// The extension icon cache doesn't clear by itself. // The extension icon cache doesn't clear by itself.
(document.querySelector(`[data-store="settings,general,showApplicable"]`)) (document.querySelector(`[data-store="settings,general,showApplicable"]`))
? document.querySelectorAll(`[data-store="settings,general,showApplicable"]`).forEach((ELEMENT) => { ? document.querySelectorAll(`[data-store="settings,general,showApplicable"]`).forEach((ELEMENT) => {
@ -102,9 +89,11 @@ class Page_Settings extends Page {
}) })
: false; : false;
(document.querySelectorAll(`[data-action]`)).forEach((ELEMENT) => { (document.querySelectorAll(`[data-action]`))
ELEMENT.removeAttribute(`data-action`); ? (document.querySelectorAll(`[data-action]`)).forEach((ELEMENT) => {
}) ELEMENT.removeAttribute(`data-action`);
})
: false;
} }
} }