use the new checking module

This commit is contained in:
buzz-lightsnack-2007 2024-04-26 22:55:06 +08:00
parent 2372e09c6d
commit aaa33b3d39
2 changed files with 8 additions and 19 deletions

View file

@ -5,20 +5,20 @@ import Tabs from "/scripts/GUI/tabs.js";
import MenuEntry from "./menu.js"; import MenuEntry from "./menu.js";
import ManagedSidebar from "./sidebar.js"; import ManagedSidebar from "./sidebar.js";
import IconIndicator from "./icons.js"; import IconIndicator from "./icons.js";
import filters from '../../filters.js'; import check from "/scripts/external/check.js";
export default class EntryManager { export default class EntryManager {
constructor () { constructor () {
this.instances = {}; this.instances = {};
this.instances.menu = new MenuEntry(); this.instances.menu = new MenuEntry();
Tabs.addActionListener(`onActivated`, (data) => {this.check()}); Tabs.addActionListener(`onActivated`, (data) => {this.onRefresh()});
} }
async check() { async onRefresh() {
const DATA = await Tabs.query(null, 0) const DATA = await Tabs.query(null, 0)
if (DATA.url) { if (DATA.url) {
(!!await ((new filters).select(DATA.url))) (!!await check.platform(DATA.url))
? (this.enable()) ? (this.enable())
: (this.disable()) : (this.disable())
}; };

View file

@ -2,25 +2,13 @@
Be sensitive to changes and update the state. Be sensitive to changes and update the state.
*/ */
import filters from "/scripts/filters.js"; 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";
export default class watchman { export default class watchman {
/* Check the current URL.
@param {string} URL the page URL; default value is the current webpage
@return {dictionary} the filter to follow
*/
static async observe(URL = window.location.href) {
// Create the variable to determine the corresponding key.
let activity = await (new filters).select(URL);
return activity;
}
/* Act on the page. /* Act on the page.
@param {dictionary} filters the filter to work with @param {dictionary} filters the filter to work with
@ -48,10 +36,11 @@ export default class watchman {
// Set the icon to indicate that it's not active. // Set the icon to indicate that it's not active.
} }
static async job() { static job() {
/* The main action. */ /* The main action. */
(watchman.observe()).then((RULES) => { (check.platform()).then((RULES) => {
console.log(RULES);
if (RULES && Object.keys(RULES).length !== 0) { if (RULES && Object.keys(RULES).length !== 0) {
watchman.act(RULES); watchman.act(RULES);
} else { } else {