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

367
Visualizações
Why is chrome.action.onClicked.addListener not working?

Why does clicking the action icon in chrome not return a result?

I'm developing in chrome and want to console.log when the action icon is clicked. Looking at the console, the first script in my background.js file works (tracking the current URL), however, nothing is returned when the icon is clicked. Any idea what I'm doing wrong? Thanks!

manifest.json

{
  "manifest_version": 3,
  "name": "Chrome Extension with React & Webpack",
  "options_page": "options.html",
  "background": { "service_worker": "background.bundle.js" },
  "action": {
    "default_title": "Click to show an alert"
  },
  "permissions": ["activeTab", "scripting", "tabs"],
  "chrome_url_overrides": {
    "newtab": "newtab.html"
  },
  "icons": {
    "128": "icon-128.png"
  },
  "content_scripts": [
    {
      "matches": ["http://*/*", "https://*/*", "<all_urls>"],
      "js": ["contentScript.bundle.js"],
      "css": ["content.styles.css"]
    }
  ],
  "devtools_page": "devtools.html",
  "web_accessible_resources": [
    {
      "resources": ["popup.html", "content.styles.css", "icon-128.png", "icon-34.png"],
      "matches": [],
       "extension_ids": []
    }
  ]
}

Background.js

//This works
chrome.tabs.onUpdated.addListener(function () {
  console.log("TAB UPDATED")
  getTab().then(url => {
      console.log(url);
  })
})

async function getTab() {
  let queryOptions = { active: true, currentWindow: true };
  let tabs = await chrome.tabs.query(queryOptions);
  return tabs[0].url;
}

//Nothing is console logged
chrome.action.onClicked.addListener(tab => { console.log('test')});

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