Using NOTY JS notification library in Chrome extension

262 Views Asked by At

I am trying to use Noty, the notification library, in a Chrome Extension.

It says you can install via:

<link href="lib/noty.css" rel="stylesheet">
<script src="lib/noty.js" type="text/javascript"></script>

I tried adding that to my content script .html, however, calling for a new notification in the .js page fails.

{
  "name": "--",
  "version": "1.0",
  "description": "--",
  "background": {
    "scripts": ["background.js"],
    "persistent": false
  },
  "content_scripts": [
    {
      "matches": ["-removed-"],
      "js": ["popup.js"]           **where I am trying to fire off a notification**
    }
  ],
  "manifest_version": 2,
  "browser_action": {
    "default_popup": "popup.html"  **where I added the script and link**
  },
  "permissions": [
    "storage",
    "notifications"
  ]
}

I have read some various threads and am not understanding the entire process. Is this a complete no-no, or is it fairly reasonable to do? I just need to be able to call for a notification in the popup.js file.

1

There are 1 best solutions below

0
On

As your question is not proper so i am answering this by assuming that you have difficulties on installing Noty.js. So for this, you first need to download the noty.js file using npm(npm install noty) or yarn or bower then you have to copy the .js and .css file to the directory and then you need to include via script and style tag. After that you will be able to call Noty(); If my answer is not proper and i have mistaken please clear me and feel free to ask if you have any problem.