events called from the GUI, aside from openiing the popup, are manual

This commit is contained in:
buzz-lightsnack-2007 2024-05-08 22:07:22 +08:00
parent 3d1c653138
commit c1ab94f737

View file

@ -7,22 +7,9 @@ import processor from "/scripts/external/processor.js";
import logging from "/scripts/logging.js";
import texts from "/scripts/mapping/read.js";
import {global} from "/scripts/secretariat.js";
import nested from "/scripts/utils/nested.js"
export default class watch {
/* Act on the page.
@param {object} filter the filter to work with
@param {object} options the options
*/
static async process(filter, options = {}) {
document.onreadystatechange = async () => {
if (document.readyState == 'complete' && (await global.read([`settings`, `behavior`, `autoRun`]) || ((((typeof options).includes(`object`) && options) ? Object.hasOwn(options, `override`) : false) ? options[`override`] : false))) {
new logging((new texts(`scrape_msg_ready`)).localized);
this.processed = (((options && typeof options == `object`) ? options[`override`] : false) || this.processed == null) ? new processor(filter) : this.processed;
}
}
}
static async main() {
let FILTER_RESULT = await check.platform();
@ -31,13 +18,28 @@ export default class watch {
new logging((new texts(`message_external_supported`)).localized);
watch.process(FILTER_RESULT);
// 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, {"override": true})
: false;
});
}
}
/* Act on the page.
@param {object} filter the filter to work with
@param {object} options the options
*/
static async process(filter) {
let PROCESSOR = new processor(filter, window.location.href, {"automatic": false});
const perform = (options) => {
(document.readyState == `complete`) ? PROCESSOR.run(options) : document.onreadystatechange = async () => {(document.readyState == `complete`) ? PROCESSOR.run(options) : PROCESSOR.product.status.done = .125;};
}
(await global.read([`settings`, `behavior`, `autoRun`])) ? document.onreadystatechange = async () => {perform();} : false;
// Create a listener for messages indicating re-processing.
chrome.runtime.onMessage.addListener(async (message, sender, sendResponse) => {
if (((typeof message).includes(`obj`) && !Array.isArray(message)) ? message[`refresh`] : false) {
perform((message[`refresh`] == `manual`) ? {"analysis": {"override": true}} : null);
};
});
};
}