From 4c604581bd64d846e22f6028d002cf76fca2f10a Mon Sep 17 00:00:00 2001 From: buzz-lightsnack-2007 <73412182+buzz-lightsnack-2007@users.noreply.github.com> Date: Sat, 27 Apr 2024 10:54:49 +0800 Subject: [PATCH] add background listener for sidebar --- scripts/GUI/entrypoints/sidebar.js | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/scripts/GUI/entrypoints/sidebar.js b/scripts/GUI/entrypoints/sidebar.js index c386a79..079e155 100644 --- a/scripts/GUI/entrypoints/sidebar.js +++ b/scripts/GUI/entrypoints/sidebar.js @@ -1,8 +1,21 @@ import Sidebar from '/scripts/GUI/sidepanel.js' export default class ManagedSidebar { - constructor () { - // WIP - new Sidebar(`/pages/popup.htm`); - } + static manage() { + chrome.runtime.onMessage.addListener( + function(request, sender, sendResponse) { + if (request.action.includes("sidebar_open")) { + ManagedSidebar.enable(); + } + } + ); + } + + static enable() { + new Sidebar(`/pages/popup.htm`); + } + + disable() { + + } } \ No newline at end of file