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

398
Views
Chrome Extension Content-Script como oyente y ventana emergente como remitente, pero da el extremo receptor no existe

Respuesta encontrada
Esta extensión es para google meet. Lo que he escrito en manifest.json está mal, la línea "matches": ["*://*.meet.google.com/*"], debería ser "matches": ["*://meet.google.com/*"],

Pregunta inicial
Tengo esta extensión de Chrome, quiero dejar que mi contentScript.js busque un elemento (etiqueta) en una página web cuando presiono un botón en popup.html. Configuré la parte del mensaje de envío en popup.js y el envío parece funcionar bien. Pero cuando traté de recibirlo en contentScript.js, console.log me da Unchecked runtime.lastError: Could not establish connection. Receiving end does not exist.

Que alguien me ayude por favor, cualquier sugerencia es bienvenida.

Fragmentos de código:
emergente.js

 retrieveTabId(); function retrieveTabId() { chrome.tabs.query({currentWindow: true, active: true}, function (tabs) { var activeTab = tabs[0]; console.log("tabID", activeTab.id); tabId = activeTab.id; }); } document.getElementById("btn").addEventListener('click', function (){ chrome.tabs.sendMessage(tabId, {type: "listener"}, function(response) { console.log((response.success)); }); console.log("tabID", tabId); })

contenido-script.js

 chrome.runtime.onMessage.addListener( function (request, sender, sendResponse) { if (request.type == 'listener') { try { let textarea = document.getElementsByTagName('textarea'); if (textarea.length == 0) { sendResponse({success: false}); } else { console.log('find node -- textarea' + textarea); sendResponse({success: true}); } } catch (e){ console.log(e); sendResponse({success: false}); } } } );

manifiesto.json

 { "name": "name", "description": "Build an Extension!", "version": "1.0", "manifest_version": 3, "permissions": ["storage", "activeTab", "scripting", "downloads", "notifications", "<all_urls>", "tabs"], "action": { "default_popup": "popup.html" }, "background": { "service_worker": "background.js" }, "content_scripts": [{ "matches": ["*://*.meet.google.com/*"], "js": ["contentScript.js"] }] }
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!