send message to open sidebar in the background

This commit is contained in:
buzz-lightsnack-2007 2024-04-27 10:53:04 +08:00
parent 3eede224d4
commit bec1de898e

View file

@ -6,45 +6,39 @@ import check from "/scripts/external/check.js";
import processor from "/scripts/external/processor.js"; import processor from "/scripts/external/processor.js";
import logging from "/scripts/logging.js"; import logging from "/scripts/logging.js";
import texts from "/scripts/mapping/read.js"; import texts from "/scripts/mapping/read.js";
import {read} from "/scripts/secretariat.js";
export default class watchman { export default class watchman {
/* Open relevant graphical user interfaces.
*/
static callGUI() {
// Open the side panel if set by default.
read([`settings`,`behavior`,`autoOpen`]).then((result) => {
if (result) {chrome.runtime.sendMessage('sidebar_open')};
});
}
/* Act on the page. /* Act on the page.
@param {dictionary} filters the filter to work with @param {dictionary} filter the filter to work with
@return {boolean} the state
*/ */
static act(matches) { static process(filter) {
// Let user know that the website is supported, if ever they have opened the console. // Let user know that the website is supported, if ever they have opened the console.
new logging((new texts(`message_external_supported`)).localized); new logging((new texts(`message_external_supported`)).localized);
// Show loading screen while the load is incomplete.
// Begin only when the page is fully loaded. // Begin only when the page is fully loaded.
window.addEventListener(`DOMContentLoaded`, (event) => { window.addEventListener(`DOMContentLoaded`, (event) => {
// Begin processing. // Begin processing.
let PROC = new processor(matches); let PROC = new processor(filter);
// Remove the loading screen.
}); });
} }
/* Set the program to standby utnil next load.
*/
static standby() {
// Set the icon to indicate that it's not active.
}
static job() { static job() {
/* The main action. */ /* The main action. */
(check.platform()).then((RULES) => { (check.platform()).then((RULES) => {
console.log(RULES); if (RULES && Object.keys(RULES).length > 0) {
if (RULES && Object.keys(RULES).length !== 0) { watchman.process(RULES);
watchman.act(RULES); watchman.callGUI();
} else {
watchman.standby();
} }
}); });
} }