From 6971f2fb3ca357c3f0342fd871b3bdc1a858a2fd Mon Sep 17 00:00:00 2001 From: buzz-lightsnack-2007 <73412182+buzz-lightsnack-2007@users.noreply.github.com> Date: Sun, 28 Apr 2024 16:57:11 +0800 Subject: [PATCH] Allow the creation and removal of action events related to the popup --- scripts/GUI/extensionIcon.js | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/scripts/GUI/extensionIcon.js b/scripts/GUI/extensionIcon.js index e41c7d8..ec1dcd4 100644 --- a/scripts/GUI/extensionIcon.js +++ b/scripts/GUI/extensionIcon.js @@ -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}; \ No newline at end of file