Tampermonkey GM_xmlhttpRequest not work properly

1.4k views Asked by At

Now i'll show you my script,that today not work properly (three months ago work,today don't work)

// ==UserScript==
// @name         My Fancy New Userscript
// @namespace    http://*/*
// @version      0.1
// @description  enter something useful
// @author       You
// @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 the problem?Why doesn't work this script? I want to make an alert box that display me some meteo data. I tried to log the state of request,but the console log me only start,perhaps the request is not make. Perhaps i stand what is wrong.I don't respect the CORS rule,and for this it doesn't work.But i can explain myself why this script work perfectly before this error if i don't change anything?

0

There are 0 answers