User:Shanel/monobook.js

/* */ /************* mw.loader.load('//meta.wikimedia.org/w/index.php?title=User:Shanel/global.js&action=raw&ctype=text/javascript');
 * global scripts

/*
 * 1) formDefaults[dev]
 * 2)  by Pathoschild
 * 3)    * automatically inserts default form values.
 * 1)    * automatically inserts default form values.

function formDefaults { /* variables */ var strFullUrl = location.href; var regFormEdit = /&action=(?:edit|submit)/; var regFormMove = /Special:Movepage/; var regFormDelete = /&action=delete/; var regFormUndelete = /Special:Undelete/; var regFormProtect = /&action=protect/; var regFormBlock = /Special:Blockip/; var regFormUnblock = /&action=unblock/;

/* get current and fill */ if(strFullUrl.match(regFormDelete)) { var objReason = fPageData('currentforminput'); objReason.value = 'Unneeded userpage for an indefinitely blocked user'; var watchbox = document.getElementById('wpWatch'); watchbox.checked = true; objReason.focus; }	else if(strFullUrl.match(regFormUnblock)) { var objReason = fPageData('currentforminput'); objReason.value = 'Override autoblock'; objReason.focus; } }

addOnloadHook(function {formDefaults});

///////////////////////////////////////////////////////////////////////////////////////////// // Started with code blatently stolen from User:Bmicomp/monobook.js. // Modified to use test-n, test2-n and test3-n. Remember to put the article title in the tag. // See User:Drini for information on the -n templates. // Menu tabs and some other functions stolen from User:alphax //  Requires additions to monobook.css for menu tabs to work

// Helper tools document.write(' '); //

//Sam's godmodeuber. Only works for admins. document.write('<\/SCRIPT>');

// Call function to load when needed. if (window.addEventListener) window.addEventListener("load",myLoadFuncs,false); else if (window.attachEvent) window.attachEvent("onload",myLoadFuncs); else {   window.previousLoadFunction = window.onload; window.onload = function {       window.previousLoadFunction; myLoadFuncs; } }

// Load custom functions. function myLoadFuncs { // Add more toolbox links addToolBoxLinks; // Add navbar links addNavBarLinks // Edit to top of page scetion addEditSection0; // Load custom tabs add_tabs; // Add a tad to purge page cache addPurge // Button to auto copyvio pages autocopyvio; // Automate add to AfD autovfd; // re-render the title and accesskeys for stuff akeytt; }

/**** Add generic tab ****/

function addlilink(tabs, url, name, id){ var na = document.createElement('a'); na.href = url; na.appendChild(document.createTextNode(name)); var li = document.createElement('li'); li.id = name; li.appendChild(na); tabs.appendChild(li); return li; }

/**** Add tab as menu ****/

function addlimenu(tabs, name, id) {   var na = document.createElement('a'); na.href = '#'; var mn = document.createElement('ul'); na.appendChild(document.createTextNode(name)); var li = document.createElement('li'); li.id = id; li.className = 'tabmenu'; li.appendChild(na); li.appendChild(mn); tabs.appendChild(li); return li; }

/**** Add purge tab ****/

function addPurge {   ta['ca-purge'] = ['g', 'Purge the internal cache for this page']; if(!document.getElementById) return; var x = document.getElementById('ca-history'); var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0]; if(!x) return; if(x.children) x = x.children[0]; else x = x.childNodes[0]; addlilink(tabs, x.href.replace(/=history/, "=purge"), 'purge', 'ca-purge'); } // appends msg to the currently-editted page, sets the summary to summ, // and marks or unmarks the Watch this page checkbox according to watch. function edit_summary_watch(msg, summ, watch) { var f = document.editform, t = f.wpTextbox1; if (t.value.length > 0) t.value += '\n'; t.value += msg; f.wpSummary.value = summ; f.wpWatchthis.checked = watch; }

// appends msg to the currently-editted page, sets the summary to summ, // and marks or unmarks the Watch this page checkbox according to watch. function add_del_tag(msg, summ, watch) { var f = document.editform, t = f.wpTextbox1; msg += '\n'; msg += t.value; t.value = msg; f.wpSummary.value = summ; f.wpWatchthis.checked = watch; }

//************************************ Edit lead section ***************************** //From http://en.wikipedia.org/w/index.php?title=User:ABCD/monobook.js&oldid=19452182 function addEditSection0{ ta['ca-edit-0'] = ['', 'Edit the zeroth section of this page']; if(!document.getElementById) return; var x = document.getElementById('ca-edit'); if(!x) return; var y = document.createElement('LI'); y.id = 'ca-edit-0'; if(x.className == 'selected'){ if(/&action=edit&section=0$/.test(window.location.href)){ x.className = 'istalk'; y.className = 'selected'; } else { x.className = 'selected istalk'; }   } else if(x.className == 'selected istalk'){ if(/&action=edit&section=0$/.test(window.location.href)){ x.className = 'istalk'; y.className = 'selected istalk'; } else { y.className = 'istalk'; }   } else { y.className = x.className; x.className = 'istalk'; }   var z = document.createElement('A'); if(x.children){ z.href = x.children[0].href + '&section=0'; z.appendChild(document.createTextNode('0')); y.appendChild(z); x.parentNode.insertBefore(y,x.nextSibling); }else{ z.href = x.childNodes[0].href + '&section=0'; z.appendChild(document.createTextNode('0')); y.appendChild(z); x.parentNode.insertBefore(y,x.nextSibling); } }

function blockuser(msg, other) { var f = document.getElementsByName('wpBlockReason')[0]; f.value = msg; var j = document.getElementsByName('wpBlockOther')[0]; j.value = other; }

// Change the names of links at the top of pages. function changeLinks {   if(!document.getElementById) return; // remove the "my" bits document.getElementById('pt-mytalk').firstChild.innerHTML = 'talk'; document.getElementById('pt-watchlist').firstChild.innerHTML = 'watchlist'; document.getElementById('pt-mycontris').firstChild.innerHTML = 'contributions'; // Change tab names document.getElementById('ca-edit').firstChild.innerHTML = 'Edit'; document.getElementById('ca-talk').firstChild.innerHTML = 'Talk'; }

// Add more personal links to the tollbox section. function addToolBoxLinks {   var tb = document.getElementById('p-tb').getElementsByTagName('ul')[0]; addlilink(tb, '/wiki/Wikipedia:Template messages/User_talk_namespace', 'Talk templates', ''); addlilink(tb, '/wiki/Wikipedia:Template_messages', 'Templates', ''); addlilink(tb, '/wiki/WP:CSD', 'SD criteria', ''); addlilink(tb, '/wiki/Special:Log', 'Log', ''); addlilink(tb, '/wiki/Special:Log/delete', 'Delete log', ''); addlilink(tb, '/wiki/Special:Log/block', 'Block log', ''); addlilink(tb, '/wiki/Special:Ipblocklist', 'IPBlocklist', ''); addlilink(tb, '/wiki/Category:Request for Unblock', 'Unblock requests', ''); addlilink(tb, '/wiki/Category:Wikipedia spam cleanup', 'Spam cleanup', ''); }

function addNavBarLinks {      var navbar = document.getElementById('p-navigation').getElementsByTagName('ul')[0]; var afdtime = new Date; var months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']; addlilink(navbar, '/wiki/Wikipedia:Articles_for_deletion/Log/' + afdtime.getUTCFullYear       + '_' + months[afdtime.getUTCMonth] + '_' + afdtime.getUTCDate, 'Todays AfD', ''); afdtime.setUTCDate(afdtime.getUTCDate - 5); addlilink(navbar, '/wiki/Wikipedia:Articles_for_deletion/Log/' + afdtime.getUTCFullYear       + '_' + months[afdtime.getUTCMonth] + '_' + afdtime.getUTCDate, '5-day old AfD', ''); var username=document.getElementById("pt-userpage").textContent; addlilink(navbar, '/w/index.php?title=User:' + username + '/Status&action=edit', 'Edit my status', ''); }

/**** Make old AfD's appear or disappear ****/

function hideafd {   var divs = document.getElementsByTagName("div"); for(var x = 0; x < divs.length; ++x) if(divs[x].className.indexOf("vfd") != -1) divs[x].style.display = "none"; // needed to shrink the page - rendering bug document.getElementById('footer').style.display = 'none'; }

function showafd {   var divs = document.getElementsByTagName("div"); for(var x = 0; x < divs.length; ++x) if(divs[x].className.indexOf("vfd") != -1) divs[x].style.display = ""; // might as well put it back... document.getElementById('footer').style.display = ''; }

// Add test-n templates to user talk pages function testn(number) { var page = prompt("Vandalism to which article?") var f = document.editform, t = f.wpTextbox1; if (t.value.length > 0) t.value += '\n'; t.value += "" + page + " ~"; f.wpSummary.value = "Your edits to " + page + "" document.editform.wpWatchthis.checked = false; }

// adds various tabs and menu tabs function add_tabs { var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0]; var username=document.getElementById("pt-userpage").textContent;

// Only add for pages with "Editing User talk:" somewhere in the title if (document.title.indexOf("Editing User talk:") != -1) {     addlimenu(tabs, 'Talk messages', 'talkm'); var talkm = document.getElementById('talkm').getElementsByTagName('ul')[0]; addlilink(talkm,'javascript:edit_summary_watch(" -- ~", "Welcome to Wikipedia!", true, 1)','Welcome', ''); addlilink(talkm,'javascript:edit_summary_watch(" -- ~", "Welcome to Wikipedia!", true, 1)','Anon', ''); addlilink(talkm, 'javascript:testn(1)', 'Test1', ''); addlilink(talkm,'javascript:testn("1a")','Test1a', ''); addlilink(talkm,'javascript:testn(2)','Test2', ''); addlilink(talkm,'javascript:testn("2a")','Test2a', ''); addlilink(talkm,'javascript:testn(3)','Test3', ''); addlilink(talkm,'javascript:testn("3a")','Test3a', ''); addlilink(talkm,'javascript:edit_summary_watch(" -- ~", "Last warning", false, 1)','Test4', ''); addlilink(talkm,'javascript:testn("4a")','Test4a', ''); addlilink(talkm,'javascript:edit_summary_watch("24 hours", "You have been blocked", false, 1)','Test5', ''); addlilink(talkm,'javascript:edit_summary_watch(" -- ~", "You have been blocked", false, 1)','Test6', ''); addlilink(talkm,'javascript:edit_summary_watch(" -- ~", "You have been blocked", false, 1)','Test7', ''); addlilink(talkm,'javascript:edit_summary_watch(" -- ~", "You have been blocked", false, 1)','usernameblock', ''); addlilink(talkm,'javascript:edit_summary_watch(" -- ~", "Vandalism", false, 1)','BV', ''); addlilink(talkm,'javascript:edit_summary_watch(" -- ~", "About the page you created", false, 1)','Vanity', ''); addlilink(talkm,'javascript:edit_summary_watch(" -- ~", "Adding links to Wikipedia", false, 1)','Spam1', ''); addlilink(talkm,'javascript:edit_summary_watch(" -- ~", "Spamming", false, 1)','Spam2', ''); addlilink(talkm,'javascript:edit_summary_watch(" -- ~", "Last warning for spamming", false, 1)','Spam3', ''); addlilink(talkm,'javascript:edit_summary_watch(" -- ~", "You have been blocked for spamming", false, 1)','Spam4', ''); addlilink(talkm,'javascript:edit_summary_watch(" -- ~", "", false, 1)','rvfd', ''); addlilink(talkm,'javascript:edit_summary_watch(" -- ~", "Blanking pages", false, 1)','blanking', ''); addlilink(talkm,'javascript:edit_summary_watch(" -- ~", "Blanking pages", false, 1)','blanking 2', ''); addlilink(talkm,'javascript:edit_summary_watch(" -- ~", "Blanking pages", false, 1)','blanking 3', ''); addlilink(talkm,'javascript:edit_summary_watch(" -- ~", "Blanking pages", false, 1)','blanking 4', ''); addlilink(talkm,'javascript:edit_summary_watch(" -- ~", "", false, 1)','nothanks-sd', ''); }

if(document.title.indexOf("Editing Wikipedia:Articles for deletion") != -1){                 // AfD tabs addlimenu(tabs, 'AfD close actions', 'afda'); var afda = document.getElementById('afda').getElementsByTagName('ul')[0]; addlilink(afda, 'javascript:closevfd("Delete", "")', 'Delete', ''); addlilink(afda, 'javascript:closevfd("Speedy Delete", "")', 'SD', ''); addlilink(afda, 'javascript:closevfd("Keep", "")', 'Keep', ''); addlilink(afda, 'javascript:closevfd("Keep (No consensus)", "")', 'Keep, NC', ''); addlilink(afda, 'javascript:closevfd("Merge and Redirect", " to " + prompt("Merge and redirect to?") + "")', 'M&R', ''); addlilink(afda, 'javascript:closevfd("Redirect", " to " + prompt("Redirect to?") + "")', 'Redirect', ''); addlilink(afda, 'javascript:closevfd("Ttranswiki", " to " + prompt("Transwiki to?"))', 'Transwiki', ''); addlilink(afda, 'javascript:closevfd("Transwiki", " to Wiktionary")', 'WIKT', ''); addlilink(afda, 'javascript:closevfd(prompt("Result?"), "")', 'Other', '');

}  if(document.title.indexOf("Wikipedia:Articles for deletion") == 0){     //Add show/hide closed AfDs addlilink(tabs, 'javascript:hideafd', 'hide closed', 'ca-hide'); ta['ca-hide'] = ['', 'Hide closed AFDs']; addlilink(tabs, 'javascript:showafd', 'show closed', 'ca-show'); ta['ca-show'] = ['', 'Show closed AFDs']; }

if (document.title.indexOf("Editing User:" + username + "/Status") == 0){ addlimenu(tabs, 'Change my status', 'mystatus'); var mystatus = document.getElementById('mystatus').getElementsByTagName('ul')[0]; addlilink(mystatus, 'javascript:edit_status("in")', 'In', ''); addlilink(mystatus, 'javascript:edit_status("out")', 'Out', ''); addlilink(mystatus, 'javascript:edit_status("around")', 'Around', ''); }

if (document.title.indexOf("Block user") == 0) {       addlilink(tabs, 'javascript:blockuser("", "indefinite")', "username"); addlilink(tabs, 'javascript:blockuser("imposter", "indefinite")', "imposter"); addlilink(tabs, 'javascript:blockuser("please contact an administrator for verification purposes, as described on this page", "indefinite")', "verification"); addlilink(tabs, 'javascript:blockuser("vandalism only account", "indefinite")', "vandalism only"); addlilink(tabs, 'javascript:blockuser("", "indefinite")', "willy"); addlilink(tabs, 'javascript:blockuser("", "indefinite")', "communism"); addlilink(tabs, 'javascript:blockuser("", "24 hours")', "revert"); addlilink(tabs, 'javascript:blockuser("vandalism - AOL", "15 minutes")', "AOL") addlilink(tabs, 'javascript:blockuser("vandalism - shared IP", "3 hours")', "shared") addlilink(tabs, 'javascript:blockuser("vandalism - returning", "1 week")', "returning"); addlilink(tabs, 'javascript:blockuser("vandalism", "24 hours")', "vandalism"); }

if (document.title.indexOf("Editing") != 0) {  } }

function closevfd(bold, notbold){ var form = document.editform; var txt = form.wpTextbox1; txt.value = " " + bold + "" + notbold + ". --~\n" + txt.value + "\n\n"; form.wpSummary.value = "Close discussion: " + bold + notbold; form.wpWatchthis.checked = false; }

/////////////////////////////////////////////////////////////////// // AutoVFD by Korath // This needs to change depending on skin used. ////////////////////////////////////////////////////////////////// function add_link2(url, name) { var na = document.createElement('a'); na.setAttribute('href', url); na.appendChild(document.createTextNode(name));

var li = document.createElement('li'); li.appendChild(na);

var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0]; tabs.appendChild(li); }

function strip_namespace(target) { var colon = target.indexOf(':'); if (colon != -1) {     var spaces = new Array('User', 'Wikipedia', 'Image', 'MediaWiki', 'Template', 'Help', 'Category'); var ns = target.substring(0, colon); if (ns == '' || ns == 'Talk') return target.substring(colon + 1); else for (var i = 0; i < spaces.length; ++i) {           if (ns == spaces[i]                || ns == spaces[i] + '_talk') return target.substring(colon + 1); }   }

return target; }

function vfd { document.editform.wpTextbox1.value = '{' + '{' + 'subst:afd}}\n' + document.editform.wpTextbox1.value; document.editform.wpSummary.value = 'afd';

var target = document.editform.action; target = target.substring(target.indexOf('title=') + 6,                           target.lastIndexOf('&action=submit'));

var months = new Array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'); var date = new Date; date = date.getUTCFullYear + '_' + months[date.getUTCMonth] + '_' + date.getUTCDate;

var pagename = strip_namespace(target);

window.open('/w/index.php?title=Wikipedia:Articles_for_deletion/' + pagename + '&action=edit&fakeaction=vfdsub&faketarget=' + target,             'Afd ' + unescape(target),              'status,toolbar,location,menubar,directories,resizeable,scrollbars'); window.open('/w/index.php?title=Wikipedia:Articles_for_deletion/Log/' + date + '&action=edit&fakeaction=vfdlist&faketarget=' + pagename,             'VfdLog ' + unescape(target),              'status,toolbar,location,menubar,directories,resizeable,scrollbars'); }

function autovfd { if (document.title.indexOf('Editing ') == 0) {     var action = ''; var target = ''; if (location.search) {         var l = location.search.substring(1).split('&'); for (var i = 0; i < l.length; ++i) {             var eq = l[i].indexOf('='); var name = l[i].substring(0, eq); if (name == 'fakeaction') action = l[i].substring(eq + 1); else if (name == 'faketarget') target = unescape(l[i].substring(eq + 1)).replace(/_/g, ' '); }       }

if (action == 'vfdlist') {         document.editform.wpTextbox1.value += '\n'; document.editform.wpSummary.value = 'Articles for deletion/' + target + ''; }     else if (action == 'vfdsub') {         if (document.editform.wpTextbox1.value.length > 0) {             target = document.editform.action; target = unescape(target.substring(target.indexOf('title=') + 6, target.lastIndexOf('&action=submit'))).replace(/_/g, ' '); window.alert("There's an old vfd at the default location already.\n\n" +                          'Please either move it out of the way (and update existing links to it), or file the Vfd by hand in another location (such as ' + target + ' (2)).'); }         else document.editform.wpTextbox1.value += '{' + '{' + 'subst:afd2|pg=' + target + '|text=' + '}' + '}' + '-- ~' + '~' + '~' + '~\n' + '\n*\'\'\' \'\'\'\n*\'\'\' \'\'\'\n*\'\'\' \'\'\'\n'; }     else add_link2('javascript:vfd', 'Afd'); } }

/////////////////////////////////////////////////////////////////// // AutoCopyvio - Created by bmicomp from modified autovfd ////////////////////////////////////////////////////////////////// function add_link2(url, name) { var na = document.createElement('a'); na.setAttribute('href', url); na.appendChild(document.createTextNode(name));

var li = document.createElement('li'); li.appendChild(na);

var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0]; tabs.appendChild(li); }

function strip_namespace(target) { var colon = target.indexOf(':'); if (colon != -1) {     var spaces = new Array('User', 'Wikipedia', 'Image', 'MediaWiki', 'Template', 'Help', 'Category'); var ns = target.substring(0, colon); if (ns == '' || ns == 'Talk') return target.substring(colon + 1); else for (var i = 0; i < spaces.length; ++i) {           if (ns == spaces[i]                || ns == spaces[i] + '_talk') return target.substring(colon + 1); }   }

return target; }

function copyvio { document.editform.wpTextbox1.value = '{' + '{' + 'copyvio|url=}}'; document.editform.wpSummary.value = 'copyvio';

var target = document.editform.action; target = target.substring(target.indexOf('title=') + 6,                           target.lastIndexOf('&action=submit'));

var months = new Array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'); var date = new Date; // date = months[date.getUTCMonth] + '_' + date.getUTCDate; var datestring = date.getUTCFullYear + '_' + months[date.getUTCMonth] + '_' + date.getUTCDate;

var pagename = strip_namespace(target);

window.open('/w/index.php?title=Wikipedia:Copyright_problems/' + datestring + '&action=edit&fakeaction=copyviolist&faketarget=' + pagename,             'status,toolbar,location,menubar,directories,resizeable,scrollbars'); }

function autocopyvio { if (document.title.indexOf('Editing ') == 0) {     var action = ''; var target = ''; if (location.search) {         var l = location.search.substring(1).split('&'); for (var i = 0; i < l.length; ++i) {             var eq = l[i].indexOf('='); var name = l[i].substring(0, eq); if (name == 'fakeaction') action = l[i].substring(eq + 1); else if (name == 'faketarget') target = unescape(l[i].substring(eq + 1)).replace(/_/g, ' '); }       }

if (action == 'copyviolist') { //         var index = document.editform.wpTextbox1.value.lastIndexOf("\n==Footer=="); /*           if (index == -1) {           window.alert("Couldn't find footer\n\n"); }          else { */ //           var firsthalf = document.editform.wpTextbox1.value.substr(0,index); //           var secondhalf = document.editform.wpTextbox1.value.substr(index); document.editform.wpTextbox1.value += '*' + target + ' (history &middot; last edit) ' + ' from [' + '] ~' + '' + '~'; document.editform.wpSummary.value = 'Copyvio ' +  + target + ; } //       }      else add_link2('javascript:copyvio', 'copyvio'); } }

//Change my traffic light status page function edit_status(status) { if (status == 'in') statnum = '3'; else if (status == 'out') statnum = '1'; else statnum = '4'; document.editform.wpTextbox1.value = ' '; document.editform.wpSummary.value = status; }

// Admin rollback tools document.write(' ');

// addOnloadHook(Dfn_js_con) function Dfn_js_con { //moves Mvaluejs_class = 'move'; //edits Rvaluejs_class = 'revert'; //uploads Uvaluejs_class = 'upload'; } //

//Interiot's javascript edit counter if (document.title.indexOf('User:Interiot/Tool2/code.js') != -1) { mw.loader.load('https://en.wikipedia.org/w/index.php?title=User:Interiot/Tool2/code.js&action=raw&ctype=text/javascript'); }

//END

/* */