Prova questo:
codice:
// ==UserScript==
// @name Google Test
// @namespace Fantasy Script
// @description Test Comandi
// @include http://www.google.it/
// ==/UserScript==
var casellaTesto = document.getElementById("lst-ib");
function setInput(list, idx) {
setTimeout(function() {
casellaTesto.value = list[idx];
}, 1000);
}
GM_xmlhttpRequest({
method: "GET",
synchronous: true,
url: "http://www.andreaemarta.it/gs/lista1.txt",
onload: function(response) {
console.log(response.responseText);
var list = response.responseText.split("\n");
console.log(list.length);
if(list.length > 0) {
if(list[list.length-1] === "") {
list = list.splice(0, list.length-1);
}
setInput(list, list.length-1);
}
}
});
A titolo di esempio, setto l'ultimo valore