0

I want to use some external CSS and JS to my chrome extenstion from the backgroung script, Suppose I want using the following files:

css/pnotify.css
js/pnotify.js

inside backgroung script I want to be able to write:

new PNotify({
   delay: 3000,
   title: 'Error',
   text: 'server not responding',
   type: 'error',
   styling: 'bootstrap3'
});

but when I'm getting error:

PNotify is not defined

I tried to add in manifest like:

"content_scripts": [{
    "css": [
        "css/pnotify.css"
    ],
    "js": [
        "js/pnotify.js"
    ]
}]

but still same error

Porky
  • 43
  • 1
  • 8
  • 1
    Content script run in web pages. The background script runs in a hidden background page so your PNotify is meaningless there. Either do everything in the content script or don't use PNotify at all, use `chrome.notifications` API instead. – wOxxOm Dec 10 '19 at 11:43

1 Answers1

0

There are already a lot of subject about your problem, amoung them this seems to answer your question => Multiple JS files in Chrome Extension - how to load them?

XwolfY
  • 104
  • 4