|
|
|
![]() |
|
Strumenti |
![]() |
#1 |
Senior Member
Iscritto dal: Dec 2007
Messaggi: 659
|
[JS][GM] Scaricare una pagina web
Se volessi scaricare una pagina web nel mio script GreaseMonkey per poter utilizzare il suo contenuto come potrei fare?
Codice:
GM_xmlhttpRequest({ method: "GET", url: "http://www.google.com/", onload: function(response) { alert(response.responseText); } }); ![]() Avete qualche idea ragazzi? ![]() |
![]() |
![]() |
![]() |
#2 |
Senior Member
Iscritto dal: Dec 2007
Messaggi: 659
|
![]() Stamattina per caso apro il Browser sulla pagina a cui è collegato lo script e funziona tutto ![]() Misteri dell'informatica.. ![]() |
![]() |
![]() |
![]() |
#3 |
Senior Member
Iscritto dal: Dec 2007
Messaggi: 659
|
Sono ancora fermo. Non va più questo benedetto metodo.
![]() Codice:
// ==UserScript== // @name Google Test // @namespace Fantasy Script // @description Test Comandi // @include http://www.google.it/ // ==/UserScript== var sceltaLista = confirm("VUoi scaricare la lista?"); GM_log(sceltaLista); if (sceltaLista) { GM_log("Sono dentro all'IF"); GM_xmlhttpRequest({ method: "GET", url: "http://www.google.it/", onreadystatechange: function(response){ GM_log(response.readyState);}, onload: function(response) { GM_log("Ho scaricato la pagina"); alert(response.responseText);} }); } function sleep(ms){ ora = new Date(); ora.setTime(new Date().getTime() + ms); while (new Date().getTime() <= ora.getTime()); } sleep(5000); Ma dal Log sembra proprio che non parte neanche lo scaricamento. "true Sono dentro all'IF" ![]() |
![]() |
![]() |
![]() |
#4 |
Senior Member
Iscritto dal: Dec 2007
Messaggi: 659
|
Ho provato a modificare il programma così:
Codice:
var sceltaLista = confirm("VUoi scaricare la lista?"); GM_log(sceltaLista); if (sceltaLista) { GM_log("Sono dentro all'IF"); GM_xmlhttpRequest({ synchronous: true, method: "GET", onerror: function (response){ GM_log(response.status);}, url: "www.google.it/", onreadystatechange: function(response){ GM_log(response.readyState);}, onload: function(response) { GM_log("Ho scaricato la pagina"); alert(response.responseText);} }); } /* function sleep(ms){ ora = new Date(); ora.setTime(new Date().getTime() + ms); while (new Date().getTime() <= ora.getTime()); } sleep(5000); */ |
![]() |
![]() |
![]() |
#5 |
Senior Member
Iscritto dal: Dec 2007
Messaggi: 659
|
Però se riduco tutto lo script a:
Codice:
GM_xmlhttpRequest({ method: "GET", onload: function(response) { GM_log("Ho scaricato la pagina"); alert(response.responseText);} }); ![]() EDIT: se aggiungo il confirm var scelta = confirm("Vuoi?"); if (scelta) GM_xmlhttpRequest({ method: "GET", onload: function(response) { GM_log("Ho scaricato la pagina"); alert(response.responseText);} }); Non funziona più..Perchè ragazzi? Ultima modifica di legolas93 : 05-01-2012 alle 11:08. |
![]() |
![]() |
![]() |
Strumenti | |
|
|
Tutti gli orari sono GMT +1. Ora sono le: 14:06.