User:Nol888/monobook.js

// Welcoming Scripts

function dowelcomegreen { document.editform.wpTextbox1.value = document.editform.wpTextbox1.value + '\n{' + '{' + 'subst' + ':' + 'W-graphical' + '}' + '}'; document.editform.wpSummary.value = 'Welcome to Wikipedia!'; document.editform.wpMinoredit.checked = false; document.editform.submit; }

function addwelcomegreen { addToolboxLink("javascript:dowelcomegreen", "Welcome User", "ca-welcomegreen", "Add Welcome Message", ""); }

//--

// Auto Status Changer Stuffs

function addstatuschanger { var subpage = "/Status"; var scheme = "/StatusTemplate"; var subpagelink = wgServer + "/w/index.php?title=User:" + encodeURIComponent(wgUserName + subpage); var contributions = document.getElementById( 'pt-mycontris' ); //Add the links-links not needed //addTopLink(subpagelink + "&action=edit&newstatus=in", "In", "pt-status-in", "I'm in!"); //addTopLink("javascript:busy", "Busy", "pt-status-busy", "I'm busy!"); //addTopLink(subpagelink + "&action=edit&newstatus=out", "Out", "pt-status-out", "I'm out!"); //Are we busy? if (location.href.indexOf("busyreason=") != -1) { var reasonRegExp = /&busyreason=(.*)/; var reasonE = reasonRegExp.exec(location.href)[1]; var reason = decodeURIComponent(reasonE); document.getElementById('wpTextbox1').value = ""; document.getElementById('wpSummary').value = status+"!"; document.getElementById('wpMinoredit').checked = 'checked'; //Submit it! document.getElementById('editform').submit; return; } if (location.href.indexOf("&action=edit&newstatus=") == -1) return; //Are we here to auto-edit the status? //Get new status and modify the form var statusRegExp = /&action=edit&newstatus=(.*)/; var status = statusRegExp.exec(location.href)[1]; document.getElementById('wpTextbox1').value = ""; document.getElementById('wpSummary').value = status+"!"; document.getElementById('wpMinoredit').checked = 'checked'; //Submit it! document.getElementById('editform').submit; }

function busy { var subpagelink = wgServer + "/w/index.php?title=User:" + wgUserName + "/Status"; var reason=window.prompt("Reason for busy:") window.location = subpagelink + "&action=edit&busyreason=" + encodeURIComponent(reason); }

//--

// Onload Hooks

$(addstatuschanger);

//--

// Twinkle Stuffs

// Twinkle Inclusion

importScript('User:AzaToth/morebits.js'); importScript('User:AzaToth/twinklefluff.js'); importScript('Wikipedia:WikiProject User scripts/Scripts/Add LI menu'); importStylesheet('Wikipedia:WikiProject User scripts/Scripts/Add LI menu/css'); importScript('User:AzaToth/twinklewarn.js'); importScript('User:AzaToth/twinklearv.js'); importScript('User:AzaToth/twinklespeedy.js'); importScript('User:AzaToth/twinklediff.js');

// Twinkle Config

TwinkleConfig = { revertMaxRevisions             :       50, userTalkPageMode               :       'window', showSharedIPNotice             :       true, openTalkPage                   :       [ 'agf', 'norm', 'vand' ], openTalkPageOnAutoRevert       :       false, openAOLAnonTalkPage            :       false, summaryAd                      :       " (this is not a bot edit) TW", deletionSummaryAd              :       " (this is not a bot edit) TW", watchSpeedyPages               :       [ 'g3', 'g5', 'g10', 'g11', 'g12' ], openUserTalkPageOnSpeedyDelete :       [ 'g1', 'g2', 'g10', 'g11', 'g12', 'a1', 'a7', 'i3', 'i4', 'i5', 'i6', 'i7', 'u3', 't1' ], watchRevertedPages             :       [ 'agf', 'norm', 'vand', 'torev' ], markRevertedPagesAsMinor       :       [ 'agf', 'norm', 'vand', 'torev' ], deleteTalkPageOnDelete         :       false, markWarningsAsMinor            :       true, markAIVReportAsMinor           :       true };

//--

/* No longer Needed 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'); }

//--

// Add Links Helper Script

//   --- ADD VARIOUS LINKS function addToolboxLink(url, name, id){ var tb = document.getElementById('p-tb').getElementsByTagName('ul')[0]; addlilink(tb, url, name, id); } // function addTopLink(url, name, id){ var personal = document.getElementById('p-personal').getElementsByTagName('ul')[0]; addlilink(personal, url, name, id); } // function addNavLink(url, name, id){ var navigation = document.getElementById('p-navigation').getElementsByTagName('ul')[0]; addlilink(navigation, url, name, id); } // function addTab(url, name, id, title, key){ var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0]; return addlilink(tabs, url, name, id, title, key); }

function addLink(where, url, name, id, title, key, after){ //* where is the id of the toolbar where the button should be added; //  i.e. one of "p-cactions", "p-personal", "p-navigation", or "p-tb". //   //* url is the URL which will be called when the button is clicked. //  javascript: urls can be used to do more complex things. //   //* name is what will appear as the name of the button. //   //* id is the id of the button; it's best to define one. //  Use a prefix to make sure its unique. Optional. //   //* title is the tooltip title that gives a longer description //  of the button; if you define a accesskey, mention it here. Optional. //   //* key is the char you want for the accesskey. Optional. //   //* after is the id of the button you want to follow this one. Optional. //   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); var tabs = document.getElementById(where).getElementsByTagName('ul')[0]; if(after) { tabs.insertBefore(li,document.getElementById(after)); } else { 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 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; }

//--

//Localized time/date script

function numToMonth(num) { if (num==0) {return "Janurary";} else if (num==1) {return "February";} else if (num==2) {return "March";} else if (num==3) {return "April";} else if (num==4) {return "May";} else if (num==5) {return "June";} else if (num==6) {return "July";} else if (num==7) {return "August";} else if (num==8) {return "September";} else if (num==9) {return "October";} else if (num==10) {return "November";} else if (num==11) {return "December";} } function monthToNum(month) { var tmp = new Date(month + " 1, 2006"); return tmp.getMonth; } function adjustTime(str, hour, minute, day, month, year, offset, s) { var time = new Date; time.setUTCHours(hour); time.setUTCMinutes(minute); time.setUTCDate(day); time.setUTCMonth(monthToNum(month)); time.setUTCFullYear(year);

var timeStr = ""; if (time.getHours<10) {timeStr += "0";} timeStr += parseInt(time.getHours) + ":"; if (time.getMinutes<10) {timeStr += "0";} timeStr += parseInt(time.getMinutes); timeStr += ", "; timeStr += time.getDate; timeStr += " "; timeStr += numToMonth(time.getMonth); timeStr += " "; timeStr += time.getFullYear; timeStr += " (UTC";  var offset = -1*time.getTimezoneOffset/60;   if (offset >= 0) {timeStr += "+";}   timeStr += offset + ")"; return timeStr; }

function adjustTime2(str, hour, minute, month, day, year, offset, s) { return adjustTime(str, hour, minute, day, month, year, offset, s); }

$(function {     if (document.title.indexOf("Editing ") == 0) {       return;      }      if (document.location.href.indexOf("action=history") != -1) {       return;      }   if (document.title.indexOf("Talk:") == 0 || document.title.indexOf("talk:") != -1 || document.title.indexOf("Wikipedia:") == 0) {      var newDoc = document.getElementById("column-content").innerHTML.replace(/(\d\d):(\d\d), (\d{1,2}) ([A-Z][a-z]+) (\d{4}) \(UTC\)/g, adjustTime);      document.getElementById("column-content").innerHTML = newDoc;   } /*   if (document.location.href.indexOf("&action=history") != -1) {      var newDoc = document.getElementById("bodyContent").innerHTML.replace(/(\d\d):(\d\d), ([A-Z][a-z]+) (\d{1,2}), (\d{4})/g, adjustTime2);      document.getElementById("bodyContent").innerHTML = newDoc;   }*/ });

//--

//Navigation Shortcuts

//

/********************************************************************** *                                                                    *  *             Changes to this file affect other users. * *           Please discuss on the talk page before editing. * *                                                                    *  **********************************************************************/

var shortcutsVersion     = "1.1.0"; var shortcutsReleaseDate = "2007-02-03";

/*********************************************************** * INTERFACE ***********************************************************/

/** * Starts a new section of links. Function for external use. */ function shortcutsStartSection (name) {  shortcutsLinks[shortcutsLinks.length] = { 'name': name, 'links': new Array  }; }

/** * Adds new link into the current section of links. Function for external use. */ function shortcutsAddLink (name, article) {  var links = shortcutsLinks[shortcutsLinks.length - 1]['links'];

links[links.length] = { 'name': name, 'article': article }; }

/*********************************************************** * IMPLEMENTATION ***********************************************************/

/** * Link maker. * Creates and returns an li element with the desired link. */ function shortcutsMakeLink (name, url) {  var ntxt = document.createTextNode (name); var na  = document.createElement ('a'); var nli = document.createElement ('li');

na.setAttribute ('href', url); nli.setAttribute ('class', 'n-shortcut');

na.appendChild (ntxt); nli.appendChild (na);

return nli; }

/** * Portlet maker. * Creates and returns a portlet populated by list of links. */ function shortcutsMakePortlet (name, links) {  var nportlet = document.createElement ('div'); var nh5 = document.createElement ('h5'); var ntit = document.createTextNode (name); var nbody = document.createElement ('div'); var nul = document.createElement ('ul');

nportlet.setAttribute ('id', 'p-'+name); nportlet.setAttribute ('class', 'portlet'); nbody.setAttribute ('class', 'pBody'); nul.setAttribute ('id', 'p-'+name);

for (var i = 0; i < links.length; i++) nul.appendChild (      shortcutsMakeLink (links[i]['name'], links[i]['article'])     );

nh5.appendChild (ntit); nportlet.appendChild (nh5); nbody.appendChild (nul); nportlet.appendChild (nbody);

return nportlet; }

/** * Main function. * Enumerates all non-empty sections, and adds new portlets beneath the old ones. */ function shortcutsMain {  var sidecol = document.getElementById ('column-one');

for (var i = 0; i < shortcutsLinks.length; i++) if (shortcutsLinks[i]['links'].length > 0) sidecol.appendChild (        shortcutsMakePortlet (shortcutsLinks[i]['name'], shortcutsLinks[i]['links'])       ); }

/** * Initializes the onload events. */ function shortcutsInitialize {  shortcutsInit ; shortcutsMain ; }

/*********************************************************** * INITIALIZATION ***********************************************************/

var shortcutsLinks = new Array ; shortcutsStartSection (wgUserName ? wgUserName : 'shortcuts');

addOnloadHook (shortcutsInitialize);

//

function shortcutsInit { var subpagelink = wgServer + "/w/index.php?title=User:" + encodeURIComponent(wgUserName + "/Status"); shortcutsStartSection ('pages to check');

shortcutsAddLink ( 'Bots:RfA',                     '/wiki/Wikipedia:Bots/Requests_for_approval' ); shortcutsAddLink ( 'AIV',                          '/wiki/WP:AIV' ); shortcutsAddLink ( 'RfA',                          '/wiki/WP:RFA' ); shortcutsAddLink ( 'Articles for Creation',        '/wiki/WP:AFC' ); shortcutsStartSection ('wikipedia important things'); shortcutsAddLink ( 'Templates for AFC',            '/wiki/WP:AFC/Templates' ); shortcutsAddLink ( 'RfC: User Names',              '/wiki/WP:RFC/NAME' ); shortcutsAddLink ( 'WP:M',                         '/wiki/Category:Wikipedia_maintenance' );

shortcutsStartSection ('personal links');

shortcutsAddLink ( 'Edit monobook.js',             '/w/index.php?title=User:Nol888/monobook.js&action=edit' ); shortcutsAddLink ( 'Welcome User',                 'javascript:dowelcomegreen' ); shortcutsAddLink ( 'Status: Online',               subpagelink + '&action=edit&newstatus=in' ); shortcutsAddLink ( 'Status: Busy',                 'javascript:busy' ); shortcutsAddLink ( 'Status: Offline',              subpagelink + '&action=edit&newstatus=out' ); }

//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'); }

//Lupin's javascript edit counter

// Script from User:Lupin/editcount.js importScript('User:Lupin/editcount.js'); //User:Lupin/editcount.js popupEditCounterTool='custom'; popupEditCounterUrl='http://en.wikipedia.org/wiki/User:$1?ectarget=$1';

// User:Outriggr/metadatatest.js importScript('User:Outriggr/metadatatest.js'); defaultProject = "WPAVIATION";