Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

365
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda