KDJ
KDJ

Reputation: 135

Import a library into a chrome extension content script?

I am looking to import a library into one of my chrome extension's content scripts. Lets take chart.js for instance. I've already looked at this post, but I'm not sure if it is what I need. If it is, then I must be doing something wrong, as I can't seem to get it to work.

I've looked everywhere but I can't seem to find anything regarding the use of libraries in chrome extensions.

Put simply, how can I use and import a javascript library into my chrome extension's content script, so that it can be used in the loaded page?

Thanks, KDJ

What I'm trying now:

chart.js is this file: enter image description here

manifest.json:

enter image description here

In my injected script: enter image description here

Error: enter image description here

chrome.tabs.executeScript() is what spawns the script in which I'm trying to access the library.

Upvotes: 3

Views: 4326

Answers (1)

Przemo
Przemo

Reputation: 1

I don't know why but for some libraries it is necessary to remove extension from chrome and add it again.

Upvotes: 0

Related Questions