User:JuhkoDev/patrol.js

//Tuoreet muutokset // addOnloadHook(patrol); var prec; var orequest2; function patrol { var bodye = document.getElementsByTagName('body') [0]; //Body-elementti //Lista prec=document.createElement('div'); prec.setAttribute('id','prec'); prec.setAttribute('style','display:none; font-size:11px; line-height:1em; position:fixed; bottom:0; right:0; width:400px; height:400px; background-color:white; border:1px solid gray;'); bodye.appendChild(prec); //Päivitys prre=document.createElement('div'); prre.setAttribute('id','prre'); prre.setAttribute('style','position:fixed; bottom:320px; right:0px; z-index:4; width:40px; height:40px; cursor:pointer; display:none;'); prre.setAttribute('onClick','precContent;'); prre.innerHTML=''; bodye.appendChild(prre); //Näytä tai piilota prshow=document.createElement('div'); prshow.setAttribute('id','pshowhide'); prshow.setAttribute('style','position:fixed; bottom:360px; right:0px; z-index:4; width:40px; height:40px; cursor:pointer;'); prshow.setAttribute('onClick','pShowHide;'); prshow.innerHTML=''; bodye.appendChild(prshow); prec.innerHTML=''; } function pShowHide { if(document.getElementById('prec').style.display == "none") { document.getElementById('prec').style.display = "block"; document.getElementById('prre').style.display = "block"; document.getElementById('prec').innerHTML='Wait...'; precContent; } else { document.getElementById('prec').style.display = "none"; document.getElementById('prre').style.display = "none"; } } // function pgetrec { orequest2 = new XMLHttpRequest; psURL = "/w/index.php?title=Special:RecentChanges&hidemyself=1&hidepatrolled=1&hideliu=1"

orequest2.onreadystatechange=ploadready; orequest2.open("GET",psURL,true); orequest2.setRequestHeader("User-Agent",navigator.userAgent); orequest2.send(null); } function precContent { pgetrec; }

function ploadready { if(orequest2.readyState==4) { if(orequest2.status==200) { document.getElementById("prec").innerHTML = orequest2.responseText;

var pstartpos=document.getElementById("prec").innerHTML.indexOf(' '); var pendpos=document.getElementById("prec").innerHTML.indexOf(''); document.getElementById("prec").innerHTML=rec.innerHTML.substr(pstartpos,pendpos-pstartpos);

alert(document.getElementById("prec").getElementsByTagName("a")[0].href);

} else document.getElementById("prec").innerHTML = "Error while reading page"; } }