From 9ccc8717bcb294e167d8d501a87b37f9753e02fb Mon Sep 17 00:00:00 2001 From: buzz-lightsnack-2007 <73412182+buzz-lightsnack-2007@users.noreply.github.com> Date: Mon, 6 May 2024 09:11:13 +0800 Subject: [PATCH] The listener overrides --- scripts/external/watch.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/scripts/external/watch.js b/scripts/external/watch.js index 6b91ba6..eb97e36 100644 --- a/scripts/external/watch.js +++ b/scripts/external/watch.js @@ -17,15 +17,16 @@ export default class watch { /* Act on the page. - @param {dictionary} filter the filter to work with + @param {object} filter the filter to work with + @param {object} options the options */ - static async process(filter) { + static async process(filter, options = {}) { document.onreadystatechange = async () => { - if (document.readyState == 'complete' && await global.read([`settings`, `behavior`, `autoRun`])) { + if (document.readyState == 'complete' && (await global.read([`settings`, `behavior`, `autoRun`]) || ((typeof options).includes(`object`) && options) ? options[`override`] : false)) { new logging((new texts(`scrape_msg_ready`)).localized); - let PROC = new processor(filter); + this.processed = (((options && typeof options == `object`) ? options[`override`] : false) || this.processed == null) ? new processor(filter) : this.processed; } - }; + } } static main() { @@ -39,7 +40,7 @@ export default class watch { // Create a listener for messages indicating re-processing. chrome.runtime.onMessage.addListener(async (message, sender, sendResponse) => { - (((typeof message).includes(`obj`) && !Array.isArray(message)) ? message[`refresh`] : false) ? watch.process(FILTER_RESULT) : false; + (((typeof message).includes(`obj`) && !Array.isArray(message)) ? message[`refresh`] : false) ? watch.process(FILTER_RESULT, {"override": true}) : false; }); } });