browser.runtime.sendMessage({ greeting: "hello" }).then((response) => { console.log("Received response: ", response); }); browser.runtime.onMessage.addListener((request, sender, sendResponse) => { console.log("Received request: ", request); if (request.action === "shortenURL") { const currentURL = window.location.href; browser.runtime.sendNativeMessage("cc.waifus.ShortWaifus.Extension", currentURL) .then(response => { if (response && !response.startsWith("Error:")) { navigator.clipboard.writeText(response) .then(() => { alert(`URL acortada y copiada al portapapeles:\n${response}`); }) .catch(err => { alert(`URL acortada: ${response}\n(No se pudo copiar al portapapeles)`); }); } else { alert(`Error al acortar la URL: ${response}`); } }) .catch(error => { alert("Error al comunicarse con la extensión"); console.error(error); }); } return true; });