Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

199
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda