Estoy tratando de pasar datos de background.js a popup.js , en el archivo de fondo está dando el error:
Uncaught (in promise) Error: Could not establish connection. Receiving end does not exist.El código se da a continuación:
fondo.js
var currentUrl = ''; chrome.tabs.query( { lastFocusedWindow: true, active: true }, function (tabs) { console.log('Active Tab') currentUrl = tabs[0].url chrome.runtime.sendMessage({ msg: "From Background" }) });emergente.js
document.addEventListener("DOMContentLoaded", function() { chrome.runtime.onMessage.addListener(function(request, sender, sendResponse){ console.log("From popup.js") console.log(request.msg) }) });Manifiesto
"manifest_version": 3, // "icons": { // "16": "/images/icon-16x16.png", // "32": "/images/icon-32x32.png", // "48": "/images/icon-48x48.png", // "128": "/images/icon-128x128.png" // }, "background": { "service_worker": "background.js" }, "action": { "default_popup": "index.html", "default_title": "Agile SEO Super Cluster", "default_icon": { "16": "16x16.png", "32": "32x32.png" } }, "permissions": [ "storage", "activeTab", "scripting", "tabs" ], "host_permissions": [ "https://www.google.com/*" ] }