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

284
Views
El trabajador del servicio no escucha la acción cuando se hace clic en el ícono de la barra de herramientas - Chrome Extension v3

Soy nuevo en esto.

Tengo un requisito, que debería abrir una nueva pestaña al hacer clic en el icono de la barra de herramientas.

Mi archivo de manifiesto:

 { "name": "App", "description": "App", "version": "1.0", "manifest_version": 3, "icons": { "16": "icon16.png", "48": "icon48.png", "128": "icon128.png" }, "commands": { "_execute_browser_action": { "suggested_key": { "default": "Ctrl+Shift+Y" } } }, "background": { "service_worker": "background.js" }, "action": {}, "web_accessible_resources": [ { "resources": ["static/*"], "matches": ["<all_urls>"] } ], "permissions": ["activeTab", "tabs", "background"], "content_security_policy": { "extension_pages": "script-src 'self'; object-src 'self'" } }

Y mi archivo background.js

 chrome.action.onClicked.addListener(function (tab) { chrome.tabs.create({ url: chrome.runtime.getURL("index.html"), active: true, }); });

Actualmente, este código abre una nueva pestaña solo una vez, y luego el trabajador del servicio se vuelve inactivo. Después de recargar la extensión solo puedo abrir la nueva pestaña. ¿Existe alguna solucion para esto?

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Parece que este error de Chrome te afecta:

Problema 1316588 : browserAction no se envía cuando se hace clic en el botón de extensión

about 4 years ago · Juan Pablo Isaza Report

0

Puedo arreglar esto degradando a la versión 2 del manifiesto.

Mi archivo manifest.json :

 { "name": "App", "description": "App", "version": "1.0", "manifest_version": 2, "icons": { "16": "icon.png", "48": "icon.png", "128": "icon.png" }, "commands": { "_execute_browser_action": { "suggested_key": { "default": "Ctrl+Shift+Y" } } }, "background": { "scripts": ["background.js"], "persistent": false }, "browser_action": {}, "web_accessible_resources": ["static/*"], "permissions": ["https://*/*", "http://*/*"], "content_security_policy": "script-src 'self'; object-src 'self'" }

Y mi archivo background.js se ve así:

 chrome.browserAction.onClicked.addListener(function (tab) { chrome.tabs.create({ url: chrome.extension.getURL("index.html"), selected: true, }); });

Me referí al código fuente de daily.dev y arreglé el error.

about 4 years ago · Juan Pablo Isaza Report
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!