Skip to content

Instantly share code, notes, and snippets.

@kohki-shikata
Last active September 21, 2024 03:50
Show Gist options
  • Save kohki-shikata/d9875c0e2ee5322e8aeb451ec515c144 to your computer and use it in GitHub Desktop.
Save kohki-shikata/d9875c0e2ee5322e8aeb451ec515c144 to your computer and use it in GitHub Desktop.
// chrome.runtime.onInstalled.addListener(() => {
// console.log("Extension installed!");
// });
// src/background/service-worker.js
let myVariable = "This is a variable from the background script.";
chrome.runtime.onMessage.addListener((request, _sender, sendResponse) => {
if (request.action === "getVariable") {
sendResponse({ variable: myVariable });
}
});
// chrome.action.onClicked.addListener(async () => {
// });
chrome.sidePanel
.setPanelBehavior({ openPanelOnActionClick: true })
.catch((error) => console.error(error));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment