User:Pinky49/global.js

// // by Lorian // revert script function getElementsByClass(searchClass,node,tag) { // Function from http://www.dustindiaz.com/getelementsbyclass/ var classElements = new Array; if ( node == null ) node = document; if ( tag == null ) tag = '*'; var els = node.getElementsByTagName(tag); var elsLen = els.length; var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)"); for (i = 0, j = 0; i < elsLen; i++) { if ( pattern.test(els[i].className) ) { classElements[j] = els[i]; j++; } }  return classElements; }

// _GET code from NoGray JS Library http://www.nogray.com/new_site/ var _GET = new Array; var _uri = location.href;

var _temp_get_arr = _uri.substring(_uri.indexOf('?')+1, _uri.length).split("&");

var _temp_get_arr_1 = new Array;

for(_get_arr_i=0; _get_arr_i<_temp_get_arr.length; _get_arr_i++){ _temp_get_arr_1 = _temp_get_arr[_get_arr_i].split("="); _GET[decodeURI(_temp_get_arr_1[0])] = decodeURI(_temp_get_arr_1[1]); }

delete _uri; delete _temp_get_arr; delete _temp_get_arr_1;

function getMessage (where, user1, user2) { var message = prompt ('What message would you like to leave?', ''); window.location = '/index.php?title=' + _GET['title'] + '&action=edit&oldid=' + _GET['oldid'] + '&'+where+'=2&user1='+user1+'&user2='+user2+'&message='+message; }

addOnloadHook(function { if (location.href.match(/diff=/)) {    // Get username of submitter    var user1 = getElementsByClass('diff-otitle',null,'td'); user1 = user1[0].getElementsByTagName('a')[2].innerHTML;    var user2 = getElementsByClass('diff-ntitle',null,'td'); user2 = user2[0].getElementsByTagName('a')[3].innerHTML;    document.getElementById('contentSub').innerHTML = '(Revert / Message) (Vandalism / Message) (Warn: No content / Notice /  1st Warning / Blanking)'; } else if (location.href.match(/revert=1/)) { document.getElementById('wpSummary').value = 'Reverted edits by '+_GET['user2']+' to version ' + _GET['oldid']+' by '+_GET['user1']+''; document.getElementById('editform').submit; } else if (location.href.match(/revert=2/)) { document.getElementById('wpSummary').value = 'Reverted edits by '+_GET['user2']+' to version ' + _GET['oldid']+' by '+_GET['user1']+' ('+_GET['message']+')'; document.getElementById('editform').submit; } else if (location.href.match(/vandalism=1/)) { document.getElementById('wpSummary').value = 'Reverted vandalism by '+_GET['user2']+' to version ' + _GET['oldid']+' by '+_GET['user1']+''; document.getElementById('editform').submit; } else if (location.href.match(/vandalism=2/)) { document.getElementById('wpSummary').value = 'Reverted vandalism by '+_GET['user2']+' to version ' + _GET['oldid']+' by '+_GET['user1']+' ('+_GET['message']+')'; document.getElementById('editform').submit; } else if (location.href.match(/warn=1/)) { document.getElementById('wpSummary').value = 'No content warning'; document.getElementById('wpTextbox1').value = +; document.getElementById('editform').submit; } else if (location.href.match(/warn=2/)) { document.getElementById('wpSummary').value = 'Notice'; document.getElementById('wpTextbox1').value = +; document.getElementById('editform').submit; } else if (location.href.match(/warn=3/)) { document.getElementById('wpSummary').value = 'Warning'; document.getElementById('wpTextbox1').value = +; document.getElementById('editform').submit; } else if (location.href.match(/warn=4/)) { document.getElementById('wpSummary').value = 'Vandalism warning'; document.getElementById('wpTextbox1').value = ' '+''; document.getElementById('editform').submit; } });

//From http://en.wikipedia.org/w/index.php?title=User:JesseW/monobook.js&oldid=20755510 function addSinceTab { if (window.location.href.indexOf("&action=history&gotosince=true")!=-1) { do_since_I_last_edited }   else if (wgCanonicalNamespace != "Special") { addPortletLink("p-cactions", "/index.php?title="+wgPageName+"&action=history&gotosince=true", '', 'diff', "since"); } } function do_since_I_last_edited { var csub=document.getElementById("contentSub"); var msg=document.createElement("p"); msg.appendChild(document.createTextNode                       ("Parsing history... please wait...")); msg.className="error"; csub.insertBefore(msg, csub.firstChild)

var username=document.getElementById("pt-userpage").textContent; var hists=document.getElementById("pagehistory").getElementsByTagName('li'); for (n=0;n<hists.length;n++) { if (hists[n].getElementsByTagName("span")[0].getElementsByTagName('a')[0].textContent==username) { document.location=hists[n].childNodes[1].href; return; }       }

msg.replaceChild(document.createTextNode                        ("You have not edited this page! (recently)"),                         msg.firstChild); }

addOnloadHook(addSinceTab);

// Please leave the following line // user:Where/usertabs addOnloadHook(function { if (wgTitle.indexOf("/") != -1 || document.title.indexOf("- History -") != -1)  //no subpages or history     return;  if (wgCanonicalNamespace == "User" || wgCanonicalNamespace == "User_talk") {     var username = encodeURIComponent( wgTitle );     addPortletLink("p-cactions", wgServer + "/wiki/Special:Contributions/" + username, "Contribs", "ca-contrib", "User contributions");     addPortletLink("p-cactions", "/wiki/Special:Editcount/" + username, "Edit count", "ca-editcount", "Edit count");     addPortletLink("p-cactions", wgServer + "/index.php?title=Special:Log&type=move&user=" + username, "Page moves", "ca-pagemoves", "Page moves by this user");     addPortletLink("p-cactions", wgServer + "/index.php?title=Special:Log&type=block&page=User:" + username, "Blocks received", "ca-blog", "Blocks received by this user");     addPortletLink("p-cactions", wgServer + "/index.php?title=Special:Prefixindex&from=" + username + "&namespace=2", "Userspace", "", "List of pages in this user's userspace"); addPortletLink("p-cactions", wgServer + "/index.php?title=Special:Log&type=block&user=" + username, "Blocks given", "", "Blocks by this user"); addPortletLink("p-cactions", wgServer + "/index.php?title=Special:Log&type=protect&user=" + username, "Protections", "", "Protections by this user"); addPortletLink("p-cactions", wgServer + "/index.php?title=Special:Log&type=delete&user=" + username, "Deletions", "", "Deletions by this user"); } });

/*************** rollback ****/ function addRollback { if(wgPageName == 'Special:Recentchanges' && fcktest != true) { items = document.getElementsByTagName('ul')[0]; items = items.getElementsByTagName('li'); for(i = 0; i < items.length; i++) { checker = items[i].getElementsByTagName('a')[0].innerHTML; if(checker != 'diff') continue; var uname = items[i].getElementsByTagName('a')[3].innerHTML; var title = items[i].getElementsByTagName('a')[2].getAttribute('href'); title = title.substring(6,title.length); items[i].appendChild(document.createTextNode(' [')); newlink = document.createElement('a'); thetext = document.createTextNode('rollback'); newlink.appendChild(thetext); newlink.setAttribute('href', '/index.php?title='+title+'&action=history&rolldown=true&uname='+escape(uname)); items[i].appendChild(newlink); items[i].appendChild(document.createTextNode(']')); //items[i].innerHTML += ' [rollback</a>]'; }   } } function addHistRollback { if(document.title.indexOf("- History") != -1 && fcktest != true) { item = document.getElementById('pagehistory').getElementsByTagName('li')[0]; newlink = document.createElement('a'); thetext = document.createTextNode('rollback'); newlink.appendChild(thetext); newlink.setAttribute('onClick', 'rollbackLast'); newlink.setAttribute('href', 'javascript:rollbackLast'); item.appendChild(document.createTextNode(' [')); item.appendChild(newlink); item.appendChild(document.createTextNode(']')); //item.innerHTML += ' [rollback</a>]'; } } function addContRollback { if(wgPageName != "Special:Contributions") return;

lilinks = document.getElementsByTagName('ul')[0].getElementsByTagName('li'); for(i = 0; i < lilinks.length; i++) { str = lilinks[i].getElementsByTagName('strong'); ahr = lilinks[i].getElementsByTagName('a')[0]; if(str[0] == null || !ahr) continue; if(str[0].innerHTML.indexOf('(top)') == -1) continue;

spec = location.href.indexOf('Special:Contributions/'); copyout = location.href.substring(spec, location.href.length); copyout = copyout.substring(22,copyout.length); thelink = ahr.getAttribute('href'); lilinks[i].appendChild(document.createTextNode(' [')); newlink = document.createElement('a'); thetext = document.createTextNode('rollback'); newlink.appendChild(thetext); newlink.setAttribute('href', thelink + '&rolldown=true&uname='+escape(copyout)); lilinks[i].appendChild(newlink); lilinks[i].appendChild(document.createTextNode(']')); } } function rollbackLast { uname = document.getElementById('pagehistory'); unamea = uname.getElementsByTagName('li'); unamer = unamea[0].getElementsByTagName('a')[2].innerHTML; for(i = 1; i < unamea.length; i++) { if(unamea[i].getElementsByTagName('a')[3].innerHTML != unamer) { gohere = unamea[i].getElementsByTagName('a')[2].getAttribute('href'); lastpe = unamea[i].getElementsByTagName('a')[3].innerHTML; break; }   }    if(gohere) location.href = gohere + '&saverevision=true&unamea=' + unamer + '&unameb=' + lastpe; } function getLastRevision { if(document.title.indexOf("- History") == -1 || location.href.indexOf("rolldown=true") == -1) return; uname = document.getElementById('pagehistory'); unamea = uname.getElementsByTagName('li'); unamer = unamea[0].getElementsByTagName('a')[2].innerHTML; if(location.href.indexOf('uname='+escape(unamer)) == -1) { alert('Edit conflict, revert cancelled.'); return; }   for(i = 1; i < unamea.length; i++) { if(unamea[i].getElementsByTagName('a')[3].innerHTML != unamer) { gohere = unamea[i].getElementsByTagName('a')[2].getAttribute('href'); lastpe = unamea[i].getElementsByTagName('a')[3].innerHTML; break; }   }    if(gohere) location.href = gohere + '&saverevision=true&unamea=' + unamer + '&unameb=' + lastpe; } function goToEditPage { if(location.href.indexOf("saverevision=true") == -1) return;

edittab = document.getElementById('ca-edit').getElementsByTagName('a')[0]; editref = edittab.getAttribute('href'); location.href = editref + '&rollbacksave=true&unamea=' + queryString('unamea') + '&unameb=' + queryString('unameb'); } function saveEditPage { if(location.href.indexOf("rollbacksave=true") == -1) return; unamea = unescape(queryString('unamea')); unameb = unescape(queryString('unameb')); esumm = document.getElementById('wpSummary'); esumm.value = 'Reverted edit(s) of ' + unamea + ' (talk) to last version by ' + unameb; document.getElementById('wpMinoredit').checked = true; theform = document.getElementById('editform'); theform.submit; } var fcktest = false; function loadInitCrap { if(fcktest == true) return; addRollback; getLastRevision; goToEditPage; saveEditPage; addHistRollback; addContRollback; } mybrowser = navigator.userAgent; if(mybrowser.search(/MSIE/i) != -1 || mybrowser.search(/Safari/i) != -1) {   addOnLoadHook(loadInitCrap); } else if(mybrowser.search(/Firefox/i) == -1) { document.addEventListener('load', loadInitCrap, false); } else { document.addEventListener('DOMContentLoaded', loadInitCrap, false); } function queryString(p) { var re = RegExp('[&?]' + p + '=([^&]*)'); var matches;

if (matches = re.exec(document.location)) { try { return decodeURI(matches[1]); } catch (e) { }   }    return null; };

//