Estoy tratando de copiar las direcciones URL de todas las pestañas abiertas con javascript y luego poner las direcciones URL en un área de texto html, sin embargo, no funciona. Este es mi código.
chrome.windows.getCurrent({"populate":true}, function(currentWindow) { var tabURLs = []; var tabs = currentWindow.tabs; for (var i=0; i<tabs.length; i++) { tabURLs.push(tabs[i].url); } var textArea = document.getElementById("thing"); var text = textArea.value; tabURLs.forEach(item => text += item); }); };Tenga en cuenta que esta es una extensión de Google Chrome, ¡hágame saber cómo puedo solucionar esto!
Su código está modificando una copia del valor del elemento, no el elemento en sí.
Debe reemplazar el text += con textArea.value +=
PD El código se puede acortar:
chrome.tabs.query({}, tabs => { document.getElementById("thing").value = tabs.map(t => t.url).join('\n'); });