0

I have a chrome extension on which I want to use the aes-js external library. Specifically, I want to be able to use this library inside my "content.js" file.

I tried adding the library inside script tags in popup.html file and I also tried importing dynamically with require.

manifest.js:

{
  "name": "Extension",
  "version": "1.0",
  "manifest_version": 2,
  "content_scripts": [
    {
      "matches": ["<all_urls>"],
      "js": ["constants.js", "rules.js", "content.js"],
      "all_frames": true
    }
  ],
  "browser_action": {
    "default_popup": "./popup.html",
    "default_title": "Extension"
  },
  "options_page": "./index.html",
  "permissions": ["tabs", "*://*/*", "storage"]
}

content.js:

chrome.runtime.onMessage.addListener(function (params, sender, sendResponse) {
  // I want to use aes-js here
  // Some other code
});
coder
  • 1
  • Find a library that has includable js files and download them from CDN e.g. for [crypto-js](https://cdnjs.com/libraries/crypto-js) you'll load crypto-js.min.js and aes.min.js. P.S. Note that the browser_action popup is not related to web page or content script, it's a separate extension page shown in its own separate window. – wOxxOm Jun 25 '21 at 12:02

0 Answers0