Use less lines

due to the async method import
This commit is contained in:
buzzcode2007 2024-03-22 19:50:26 +08:00
parent c038ed9812
commit a621df9b87

View file

@ -2,8 +2,7 @@
Manage the local cache. Manage the local cache.
*/ */
export default class secretariat { export function read(prefname, cloud = false) {
static read(prefname, cloud = false) {
/* Read all storeed data in the browser cache. /* Read all storeed data in the browser cache.
Parameters: Parameters:
@ -31,9 +30,9 @@ export default class secretariat {
} }
return(pref_data); return(pref_data);
}; }
static specifics(WHERE, domain = window.location.href) { export function specifics(WHERE, domain = window.location.href) {
/* List the matching rule or memory for a particular domain. /* List the matching rule or memory for a particular domain.
Parameters: Parameters:
@ -94,23 +93,9 @@ export default class secretariat {
// Return the result. // Return the result.
return(result); return(result);
} }
static amend(WHERE, website, datas) { export function write(prefname, data) {
/* Update the rules.
Parameters:
WHERE: the data set to update
website: RegEx pattern of the website or the domain
datas: the data in JSON
Returns: (boolean) the update status
*/
};
static write(prefname, data) {
/* Write the data on the selected prefname. /* Write the data on the selected prefname.
Parameters: Parameters:
@ -119,9 +104,22 @@ export default class secretariat {
*/ */
}; }
static forget(domain) { export function amend(WHERE, SITE, DATA) {
/* Update the rules.
Parameters:
WHERE: the data set to update
SITE: RegEx pattern of the website or the domain
DATA: the data in JSON
Returns: (boolean) the update status
*/
}
export function forget(domain) {
/* Dangerous: Resets all data or a domain's data. /* Dangerous: Resets all data or a domain's data.
Parameters: Parameters:
@ -133,7 +131,7 @@ export default class secretariat {
(async () => { (async () => {
// Import alerts module. // Import alerts module.
let alerts = await import(chrome.runtime.getURL("gui/scripts/alerts.js")); let alerts = await import(chrome.runtime.getURL(`gui/scripts/alerts.js`));
// Confirm the action. // Confirm the action.
let forget_action = alerts.confirm_action(); let forget_action = alerts.confirm_action();
@ -150,21 +148,4 @@ export default class secretariat {
})(); })();
return (forget_action); return (forget_action);
};
};
export function read(prefname) {
return(secretariat.read(prefname));
};
export function specifics(WHERE, domain = window.location.href) {
return(secretariat.specifics(WHERE, domain));
}
export function amend(website, rules) {
return (secretariat.amend(website, rules));
};
export function forget(domain) {
return (secretariat.forget(domain));
}; };