firefox extension, read background script variable from popup?

21 Views Asked by At

I have a firefox extension:

background_script.js:

const textVar = "some text"

browser.menus.create({
  id: "selection-to-tg",
  title: "send selection",
  type: "normal",
  contexts: ["selection"],
});

browser.menus.onClicked.addListener((info, tab) => {
  if (info.menuItemId === "selection-to-tg") {
    browser.windows.create({
      url: "popup.html",
      type: "popup",
      width: 500,
      height: 400,
      left: 200,
      top: 200,
    });
  }
});

How do I pass textVar to the popup.html, or how can popup.html read textVar?

0

There are 0 best solutions below