User:Dpotter/monobook.js

// // User:Lupin/popups.js

mw.loader.load(            'https://en.wikipedia.org/w/index.php?title=User:Lupin/popups.js'             + '&action=raw&ctype=text/javascript&dontcountme=s'); simplePopups=true; popupRevertSummary="revert to article %s";

// stuff from Wikiproject user scripts:

function addlilink(tabs, url, name, id, title, key){ var na = document.createElement('a'); na.href = url; na.appendChild(document.createTextNode(name)); var li = document.createElement('li'); if(id) li.id = id; li.appendChild(na); tabs.appendChild(li); if(id) {       if(key && title) {           ta[id] = [key, title]; }       else if(key) {           ta[id] = [key, '']; }       else if(title) {           ta[id] = ['', title]; }   }    // re-render the title and accesskeys from existing code in wikibits.js    akeytt; return li; }

function addTab(url, name, id, title, key){ var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0]; return addlilink(tabs, url, name, id, title, key) };

//From http://en.wikipedia.org/w/index.php?title=User:JesseW/monobook.js&oldid=20755510

// addLastDiff $(function {    z=document.getElementById("content").childNodes;    for (var n=0;n<z.length;n++) {       if (z[n].className=="firstHeading") {        var pname=z[n].textContent ? z[n].textContent : z[n].innerText;      }    }    var l=addTab("http://en.wikipedia.org/w/index.php?title=" + pname + "&diff=cur&oldid=prev", 'last', '');    l.lastChild.title="Show most recent diff"; });

//

//On diff pages this script replaces (Difference between revisions)with //different tools for reverting the edit and warning the user that made the edit. //For instructions see talk page. // Revert tools by Lorian 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 = 'http://en.wikipedia.org/w/index.php?title=' + _GET['title'] + '&action=edit&oldid=' + _GET['oldid'] + '&'+where+'=2&user1='+user1+'&user2='+user2+'&message='+message; }

$(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')[2].innerHTML; if (user2='undo') {    var user2 = getElementsByClass('diff-ntitle',null,'td'); user2 = user2[0].getElementsByTagName('a')[3].innerHTML; }    var articletitle = getElementsByClass('firstHeading');articletitle=articletitle[0].innerHTML;    document.getElementById('contentSub').innerHTML = '(Revert / Message) (Vandalism / Message) (Warn: Test  / Blatant / Nonsense / Blanking / <a href="http://en.wikipedia.org/w/index.php?title=User_talk:'+ user2 + '&warnuser=yes&article='+articletitle+'">Review User Talk Page</a>)';

} 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(/warnuser=yes/)) { var user2=location.href.substring(location.href.indexOf("User_talk:")+10,location.href.indexOf("&")); var articletitle=location.href.substr(location.href.indexOf("article=")+8); document.getElementById('contentSub').innerHTML = '(Warn: <a href="http://en.wikipedia.org/w/index.php?title=User_talk:'+user2+'&action=edit&section=new&warn=1&article='+articletitle+'">Test</a> / <a href="http://en.wikipedia.org/w/index.php?title=User_talk:'+user2+'&action=edit&section=new&warn=2&article='+articletitle+'">Blatant</a> / <a href="http://en.wikipedia.org/w/index.php?title=User_talk:'+user2+'&action=edit&section=new&warn=3&article='+articletitle+'">Nonsense</a> / <a href="http://en.wikipedia.org/w/index.php?title=User_talk:'+user2+'&action=edit&section=new&warn=4&article='+articletitle+'">Blanking</a>)';

} else if (location.href.match(/warn=1/)) { var articletitle=location.href.substr(location.href.indexOf("article=")+8); document.getElementById('wpSummary').value = 'Your edits to '+ articletitle +''; document.getElementById('wpTextbox1').value = ' -- '+''; document.getElementById('editform').submit; } else if (location.href.match(/warn=2/)) { var articletitle=location.href.substr(location.href.indexOf("article=")+8); document.getElementById('wpSummary').value = 'Your edits to '+ articletitle +''; document.getElementById('wpTextbox1').value = ' -- '+''; document.getElementById('editform').submit; } else if (location.href.match(/warn=3/)) { var articletitle=location.href.substr(location.href.indexOf("article=")+8); document.getElementById('wpSummary').value = 'Your edits to '+ articletitle +''; document.getElementById('wpTextbox1').value = ' -- '+''; document.getElementById('editform').submit; } else if (location.href.match(/warn=4/)) { var articletitle=location.href.substr(location.href.indexOf("article=")+8); document.getElementById('wpSummary').value = 'Your edits to '+ articletitle +''; document.getElementById('wpTextbox1').value = ' -- '+''; document.getElementById('editform').submit; } });

//