javascript - Tampermonkey GM_xmlhttpRequest not work properly -
now i'll show script,that today not work (three months ago work,today don't work)
// ==userscript== // @name fancy new userscript // @namespace http://*/* // @version 0.1 // @description enter useful // @author // @match https://www.facebook.com/ // @grant gm_xmlhttprequest // ==/userscript== var x=document.createelement('button'); x.style.width="30px"; x.style.height="30px"; x.style.position="fixed"; x.style.top="5px"; x.style.left="1250px"; x.style.zindex="388"; x.style.backgroundrepeat="no-repeat"; x.style.backgroundsize="30px 30px"; x.style.backgroundimage="url(http://www.iconarchive.com/download/i76816/wineass/ios7-redesign/weather.ico)"; console.log("start"); x.onclick=function(){ gm_xmlhttprequest({ method: "get", url: "http://www.3bmeteo.com/meteo/cosenza", onload: function(response) { pars=new domparser(); var t=pars.parsefromstring(response.responsetext,"text/html"); var y=t.getelementsbyclassname('col-xs-2-4'); var z=t.getelementsbyclassname('col-xs-1-4 big'); var text=""; text+=y[0].innertext+" "+z[0].innertext+"\n"+y[1].innertext+" "+z[1].innertext+"\n"+y[2].innertext+" "+z[2].innertext+"\n"+y[3].innertext+" "+z[3].innertext+"\n"+y[4].innertext+" "+z[4].innertext+"\n"; alert(text); console.log("finished")} }); }; document.body.appendchild(x); var x1=document.createelement('button'); x1.style.width="30px"; x1.style.height="30px"; x1.style.position="fixed"; x1.style.top="5px"; x1.style.left="1290px"; x1.style.zindex="388"; x1.style.backgroundrepeat="no-repeat"; x1.style.backgroundsize="30px 30px"; x1.style.backgroundimage="url(http://www.iconarchive.com/download/i76816/wineass/ios7-redesign/weather.ico)"; x1.onclick=function(){ gm_xmlhttprequest({ method: "get", url: "http://www.3bmeteo.com/meteo/cosenza/1", onload: function(response) { pars=new domparser(); var t=pars.parsefromstring(response.responsetext,"text/html"); var y=t.getelementsbyclassname('big switchcelsius switch-te active'); var z=t.getelementsbyclassname('hidden-xs'); var text=""; text+="domani:"+y[0].innertext+" "+z[8].innertext+"\n"+y[1].innertext+" "+z[9].innertext+"\n"+y[2].innertext+" "+z[10].innertext+"\n"+y[3].innertext+" "+z[11].innertext; alert(text);} }); }; document.body.appendchild(x1);
what's problem?why doesn't work script? want make alert box display me meteo data. tried log state of request,but console log me start,perhaps request not make. perhaps stand wrong.i don't respect cors rule,and doesn't work.but can explain myself why script work before error if don't change anything?
Comments
Post a Comment