User:Ginsuloft/common.js

ncwf="Notification,Caution,Warning,Final warning".split(","); var monthNames="January,February,March,April,May,June,July,August,September,October,November,December".split(","); var debugg=0,dbgTA,cook9,nohdr=1; var rbl=null,talk=null,vLev=0,qweRevid,qweEditToken,qwe1,qwe2,qwe3,sp123; now=new Date;appendWarn=""; curDate=monthNames[now.getUTCMonth]+" "+now.getUTCFullYear;

function tts(x){ if(x>=730.5)return Math.floor(x/365.25)+" years"; if(x>=365.25)return "1 year"; if(x>=60.875)return Math.floor(x/30.4375)+" months"; if(x>=30.4375)return "1 month"; if(x>=2)return Math.floor(x)+" days"; if(x>=(2/24))return Math.floor(x*24)+" hours"; if(x>=(1/24))return "1 hour"; if(x>=(2/1440))return Math.floor(x*1440)+" minutes"; if(x>=(1/1440))return "1 minute"; return "less than 1 minute"; }

function zxcv(warnType){ net=new XMLHttpRequest; net.open("GET",rbl,false); net.send; wasOk=((net.responseText.indexOf("title>Action complete - W")>=0&&net.responseText.indexOf(">(No difference)<\/")<0)?1:0); if(wasOk)location.href=(talk+"\x26warnType="+warnType); else nti.innerHTML="<"+"h1>You were beaten to the revert.<\/h1>"; } Array.prototype.scan=function(x){ for(var i=0;i<this.length;i++){ if(this[i]==x)return i; } return -1; }; var asd5=document.getElementById("mw-diff-ntitle2"); var lts=0,talkpage="",tsl=[],z1,z2,z3,z4,z5,i,temp; if(asd5 && asd5.childNodes){ for(i=0;i<asd5.childNodes.length;i++){ if(asd5.childNodes[i].className=="mw-rollback-link") rbl=asd5.childNodes[i].childNodes[1].href; if(asd5.childNodes[i].className=="mw-usertoollinks") talk=asd5.childNodes[i].childNodes[1].href; } username=talk.match(/User_talk\x3A([^&]+)/)[1]; if(talk.indexOf("&action=edit&redlink=1")<0) talk=talk.replace("/wiki/User_talk:","/w/index.php?title=User_talk:")+"&action=edit"; talk+="\x26vpage="+encodeURIComponent(document.title.substr(0,document.title.indexOf(": Difference between revisions"))); }

talkpage=document.getElementById("wpTextbox1"); tbox=talkpage; if(talkpage){ // talkpage=talkpage.value; tsl=talkpage.match(/[Tt]emplate\x3A[Uu]w\x2D[a-zA-Z]+\d[\x00-\uffff]*?\d+\x3A\d+\x2C \d+ [a-zA-Z]+ \d+ \x28UTC\x29/g); if(talkpage.match(new RegExp("==.?"+curDate+".?=="))) nohdr=0; if(tsl){ // for(i=0;i<tsl.length;i++){ temp=tsl[i].match(/[Tt]emplate\x3A[Uu]w\x2D[a-zA-Z]+\d/g)[0]; tsl[i]=tsl[i].match(/\d+\x3A\d+\x2C \d+ [a-zA-Z]+ \d+ \x28UTC\x29/g)[0]; z1=tsl[i].match(/\d+/g)[3]; z2=monthNames.scan(tsl[i].match(/[a-zA-Z]+/g)[0]); z3=parseInt(tsl[i].match(/\d+/g)[2],10); z4=parseInt(tsl[i].match(/\d+/g)[0],10); z5=parseInt(tsl[i].match(/\d+/g)[1],10); tsl[i]=[temp.match(/\d/g)[0],((new Date).getTime-Date.UTC(z1*1,z2,z3,z4,z5))/86400000]; } for(i=0;i=0){ // if(tsl){ for(i=0;i"; } else qaqa="This user has not been issued any warnings.\x3Cbr>"; ndiv=document.createElement("div"); ndiv.innerHTML="\x3Cbr>Recent vandal activity: level "+vLev+"\x3Cbr>\x3Cbr>"+qaqa+"\x3Cbr>"; tbox.parentNode.insertBefore(ndiv,tbox); pag=location.href.match(/\x26vpage\x3d(.+)\x26warn/); warnType=location.href.match(/\x26warnType\x3d(.+)/); if(pag&&warnType){ // if(vLev>=4 && document.getElementsByClassName("mw-warning-with-logexcerpt").length<1){ // //alert("Please report this user to AIV."); username=location.href.match(/User_talk\x3A([^&]+)/)[1]; for(i=tsl.length-1;i>=0;i--){if(tsl[i][0]>=4){latestFinal=tsl[i][1];break;}} aivInfo="username="+encodeURIComponent(username)+"\x26time="+encodeURIComponent(tts(latestFinal)); qw23="http://en.wikipedia.org/w/index.php?title=Wikipedia:Administrator_intervention_against_vandalism&action=edit&"+aivInfo; location.href=qw23; //ndiv.innerHTML+="\x3Ca href=\""+qw23+"\" target=_blank style=color:red;font-weight:bold>Report to AIV<\/a>\x3Cbr>\x3Cbr>"; } // else if(vLev<4){ pag=decodeURIComponent(pag[1]); warnType=warnType[1]; if(nohdr)appendWarn="== "+curDate+" ==\n"; appendWarn+="\n"+pag+" \x7e~\n"; tbox.value+=appendWarn; wtwt="uw-"+warnType+""+(vLev+1); document.getElementById("wpSummary").value=ncwf[vLev]+": recent edits to "+pag+""; document.getElementById("editform").submit; } } // } // } // if(document.title.indexOf("Editing Wikipedia:Administrator intervention against vandalism")>=0 && location.href.indexOf("username=")>=0 && location.href.indexOf("time=")>=0){ if(location.href.match(/\x26username\x3d/)){ username=decodeURIComponent(location.href.match(/\x26username\x3d([^&]+)/)[1]); time=decodeURIComponent(location.href.match(/\x26time\x3d([^&]+)/)[1]); tbox=document.getElementById("wpTextbox1"); sbox=document.getElementById("wpSummary"); if((tbox.value+"").indexOf(username)>=0)alert("This user has already been reported."); else{ if(username.match(/^\d+\.\d+\.\d+\.\d+$/) || username.match(/^[A-F0-9]{1,4}\x3a[A-F0-9]{1,4}\x3a[A-F0-9]{1,4}\x3a[A-F0-9]{1,4}\x3a[A-F0-9]{1,4}\x3a[A-F0-9]{1,4}\x3a[A-F0-9]{1,4}\x3a[A-F0-9]{1,4}$/)) report="*{{IP";else report="*{{"; report+="vandal|"+username+"}} – Vandalism after a level 4 warning which was issued "+time+" ago. \x7e~"; tbox.value+=report; sbox.value="Reporting "+username+""; document.getElementById("editform").submit; } } /* else{ tbox=document.getElementById("wpTextbox1"); sbox=document.getElementById("wpSummary"); tbox.onkeyup=function{ var tmpp=tbox.value.match(/vandal\x7C[^\x7D]+\x7D/gi); var tmpp2=tmpp[tmpp.length-1]; tmpp2=tmpp2.substring(7,tmpp2.length-1); sbox.value="Reporting "+tmpp2+""; }; } } if(document.title.indexOf("fference between rev")>=0){ sp123=document.createElement("div"); var rblNew="\x3Cbr>"+ "\x3Ca href=\"#\" onclick=\"zxcv('vand');return false;\">\x3Cb>vand\x3C/b>\x3C\/a>\x26nbsp;\x26nbsp;\x26nbsp;"+ "\x3Ca href=\"#\" onclick=\"zxcv('test');return false;\">\x3Cb>test\x3C/b>\x3C\/a>\x26nbsp;\x26nbsp;\x26nbsp;"+ "\x3Ca href=\"#\" onclick=\"zxcv('delete');return false;\">\x3Cb>delete\x3C/b>\x3C\/a>\x26nbsp;\x26nbsp;\x26nbsp;"+ "\x3Ca href=\"#\" onclick=\"zxcv('unsourced');return false;\">\x3Cb>unsourced\x3C/b>\x3C\/a>\x26nbsp;\x26nbsp;\x26nbsp;"+ "\x3Ca href=\"#\" onclick=\"zxcv('nor');return false;\">\x3Cb>nor\x3C/b>\x3C\/a>\x26nbsp;\x26nbsp;\x26nbsp;"+ "\x3Ca href=\"#\" onclick=\"zxcv('error');return false;\">\x3Cb>error\x3C/b>\x3C\/a>\x26nbsp;\x26nbsp;\x26nbsp;"+ "\x3Ca href=\"#\" onclick=\"zxcv('biog');return false;\">\x3Cb>biog\x3C/b>\x3C\/a>\x26nbsp;\x26nbsp;\x26nbsp;"+ "\x3Ca href=\"#\" onclick=\"zxcv('defamatory');return false;\">\x3Cb>defamatory\x3C/b>\x3C\/a>\x26nbsp;\x26nbsp;\x26nbsp;"+ "\x3Ca href=\"#\" onclick=\"zxcv('spam');return false;\">\x3Cb>spam\x3C/b>\x3C\/a>\x26nbsp;\x26nbsp;\x26nbsp;"+ "\x3Ca href=\"#\" onclick=\"zxcv('advert');return false;\">\x3Cb>advert\x3C/b>\x3C\/a>\x3Cbr>\x3Cbr>"+ "\x3Ca href=\"#\" onclick=\"zxcv('npa');return false;\">\x3Cb>npa\x3C/b>\x3C\/a>\x26nbsp;\x26nbsp;\x26nbsp;"+ "\x3Ca href=\"#\" onclick=\"zxcv('npov');return false;\">\x3Cb>npov\x3C/b>\x3C\/a>\x26nbsp;\x26nbsp;\x26nbsp;"+ "\x3Ca href=\"#\" onclick=\"zxcv('image');return false;\">\x3Cb>image\x3C/b>\x3C\/a>\x26nbsp;\x26nbsp;\x26nbsp;"+ "\x3Ca href=\"#\" onclick=\"zxcv('create');return false;\">\x3Cb>create\x3C/b>\x3C\/a>\x26nbsp;\x26nbsp;\x26nbsp;"+ "\x3Ca href=\"#\" onclick=\"zxcv('speedy');return false;\">\x3Cb>speedy\x3C/b>\x3C\/a>\x26nbsp;\x26nbsp;\x26nbsp;"+ "\x3Ca href=\"#\" onclick=\"zxcv('tdel');return false;\">\x3Cb>tdel\x3C/b>\x3C\/a>\x26nbsp;\x26nbsp;\x26nbsp;"+ "\x3Ca href=\"#\" onclick=\"zxcv('afd');return false;\">\x3Cb>afd\x3C/b>\x3C\/a>\x26nbsp;\x26nbsp;\x26nbsp;"+ "\x3Ca href=\"#\" onclick=\"zxcv('chat');return false;\">\x3Cb>chat\x3C/b>\x3C\/a>\x26nbsp;\x26nbsp;\x26nbsp;"+ "\x3Ca href=\"#\" onclick=\"zxcv('joke');return false;\">\x3Cb>joke\x3C/b>\x3C\/a>\x26nbsp;\x26nbsp;\x26nbsp;"+ "\x3Cbr>\x3Cbr>"; sp123.innerHTML=(rbl?rblNew:"\x3Cbr>[not the latest revision]\x3Cbr>\x3Cbr>"); nti=document.getElementById("mw-diff-ntitle1"); nti.parentNode.insertBefore(sp123,nti); }