add window event listeners

This commit is contained in:
buzz-lightsnack-2007 2024-04-27 11:07:31 +08:00
parent 4c604581bd
commit f457ac5e23

View file

@ -25,4 +25,17 @@ export default class Window {
show() {
this.window = window.open(this.url, this.name, this.options);
};
/* Create an action listener.
@param {string} event the event to listen for
@param {function} callback the callback function
*/
static addActionListener(event, callback) {
// Correct possible syntax error on "on" prefix.
event = (!event.includes(`on`)) ? `on${event}` : event;
// Add the event.
chrome.windows[event].addListener(callback);
}
};