The listener overrides

This commit is contained in:
buzz-lightsnack-2007 2024-05-06 09:11:13 +08:00
parent a1d5f1f315
commit 2588b3ff30

View file

@ -17,15 +17,16 @@ export default class watch {
/* Act on the page. /* 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 () => { 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 != null) ? options[`override`] : false)) {
new logging((new texts(`scrape_msg_ready`)).localized); new logging((new texts(`scrape_msg_ready`)).localized);
let PROC = new processor(filter); this.processed = (override || this.processed == null) ? new processor(filter) : this.processed;
} }
}; }
} }
static main() { static main() {
@ -39,7 +40,7 @@ export default class watch {
// Create a listener for messages indicating re-processing. // Create a listener for messages indicating re-processing.
chrome.runtime.onMessage.addListener(async (message, sender, sendResponse) => { 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;
}); });
} }
}); });