Lo que quiero hacer:
Estoy tratando de construir una extensión de cromo. La extensión será-
text.html . Tenga en cuenta que text.html es una página fija, todo el texto se acumulará en text.html .
Mi intento:
sendMessage , algo como: function getSelectionText() { var text = ""; if (window.getSelection) { text = window.getSelection().toString(); } else if (document.selection && document.selection.type != "Control") { text = document.selection.createRange().text; } return text; } function doc_keyUp(e) { // this would test for whichever key is 40 (down arrow) and the ctrl key at the same time if (e.key === 'a') { tx_s=getSelectionText(); //console.log(tx_s); chrome.runtime.sendMessage({greeting:tx_s},function(response) {console.log(response.farewell);}); }// if (e.key === 'q') } // doc_keyUp(e) // register the handler document.addEventListener('keyup', doc_keyUp, false);recibe texto por el siguiente código:
chrome.runtime.onMessage.addListener( function(request,sender,sendResponse){ console.log(sender.tab? "from a content script"+sender.tab.url : "from the extension"); //if (request.greeting==="hello") sendResponse({farewell:request.greeting}); console.log(request.greeting); //window.greeting[0] = request.greeting; }) chrome.action.onClicked.addListener(function (tab) { chrome.tabs.create({url: 'popup.html'}) })window.bears={}; (no permite la opción de ventana).¿Cómo puedo transferir el texto de varias páginas a una acumulación y ver en un html? Gracias.