1 year ago

#382775

test-img

now_world

How to persist data in memory after closing popup extension

I'm building a chrome extension, and I'd like to have some sensitive data stored in memory (not disk) while the user has their browser open. The data should persist in the chrome extension even if the user closes the extension popup and re-opens the popup. How can I do this?

I believe this is possible because both Metamask and Bitwarden ask you for your password when you first open their extension after opening the browser. Then no matter how many times you close their extension and re-open it, the data persists, but I doubt that they are saving decrypted data to disk, so it must be kept in memory. I'd like to do the same, but whenever I try to save anything in the popup.html's JS file to memory, it never persists after closing the popup.

{
  "manifest_version": 3,
  "name": "TEST",
  "version": "1.0.0",
  "permissions": [
    "storage",
    "activeTab",
    "cookies",
    "tabs"
  ],
  "action": {
    "default_popup": "popup.html",
    "default_title": "TEST",
    "default_icon": {
      "16": "./assets/images/icon16.png",
      "19": "./assets/images/icon19.png",
      "32": "./assets/images/icon32.png",
      "38": "./assets/images/icon38.png",
      "48": "./assets/images/icon48.png",
      "128": "./assets/images/icon128.png"
    }
  },
  "icons": {
    "16": "./assets/images/icon16.png",
    "19": "./assets/images/icon19.png",
    "32": "./assets/images/icon32.png",
    "38": "./assets/images/icon38.png",
    "48": "./assets/images/icon48.png",
    "128": "./assets/images/icon128.png"
  },
  "background": {
    "service_worker": "service-worker-loader.js",
    "type": "module"
  }

google-chrome-extension

firefox-addon-webextensions

metamask

browser-extension

chrome-extension-manifest-v3

0 Answers

Your Answer

Accepted video resources