Allow the creation and removal of action events related to the popup

This commit is contained in:
buzz-lightsnack-2007 2024-04-28 16:57:11 +08:00
parent b5a35682fc
commit 6971f2fb3c

View file

@ -37,6 +37,40 @@ class BrowserIcon {
return (chrome.action[`get`.concat(detail)](((parameters) ? format(parameters) : null)));
}
/*
Add an action listener to the browser icon.
@param {string} event the event name
@param {function} callback the function to be run
*/
static addActionListener(event, callback) {
chrome.browserAction[event].addListener(callback);
};
/*
Remove an action listener to the browser icon.
@param {string} event the event name
@param {function} callback the function to be removed
*/
static removeActionListener(event, callback) {
chrome.browserAction[event].removeListener(callback);
};
/*
Enable the action event.
*/
static enable() {
chrome.action.enable();
};
/*
Disable the action event.
*/
static disable() {
chrome.action.disable();
};
};
export {BrowserIcon as default};