Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

190
Views
swal is not rendered in context menu of an chrome extension

I want to use SweetAlert for alert box in my chrome extension. SweetAlert has to be shown when clicked in context menu. I have attached the sweetalert code in background scripts property inside manifest.json. I also used the css in content_scripts. Though default alert is showing but SweetAlert is not showing.

Here is the code for manifest.json

{
  "manifest_version": 2,
  "name": "Detect Sentiment",
  "version": "1.0",
  "description": "A extension which can detect sentiment",
  "icons": {
    "128": "icon128.png",
    "48": "icon48.png",
    "16": "icon16.png"
  },
  "browser_action": {
    "default_icon": "icon16.png",
    "default_popup": "popup.html"
  },
  "background": {
    "scripts": ["eventPage.js", "sweetalert.min.js"],
    "css": ["sweetalert.css"],
    "persistent": true
  },
  "permissions": ["activeTab", "notifications", "contextMenus"]
}

Here is the code for eventPage.js

var contextMenuItem = {
  id: "detectSentiment",
  title: "Detect Sentiment",
  contexts: ["selection"],
};
chrome.contextMenus.create(contextMenuItem);

chrome.contextMenus.onClicked.addListener(function (clickData) {
  if (clickData.menuItemId == "detectSentiment" && clickData.selectionText) {
    console.log(clickData.selectionText);
    swal("Hello");
    alert(clickData.selectionText);
  }
});

How can I fix this problem?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!