User:Spinningspark/monobook.js

//Find username var uservar= mw.config.get( 'wgRelevantUserName' ); var userparam=''; if (uservar) { userparam='name='+ encodeURIComponent(uservar) +'&'; }

var userIP=false; if (uservar && uservar.match(/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/)) { userIP=true; }

//IP ranges var range24 = '0.0.0.0/24'; var range16 = '0.0.0.0/16';

if (userIP === true) { var base24 = uservar.substring(0,uservar.lastIndexOf('.')); var base16 = base24.substring(0,base24.lastIndexOf('.')); range24 = base24 + '.0/24'; range16 = base16 + '.0.0/16'; }

//Date formatting

var hitDate = new Date; var hitMonth = hitDate.getMonth+1; //Date counts months from zero; var hitDay = hitDate.getDate; var MonthLeading0 = ''; if (hitMonth < 10) {MonthLeading0 = '0';} else {MonthLeading0 = '';} var DayLeading0 = ''; if (hitDay < 10) {DayLeading0 = '0';} else {DayLeading0 = '';}

var YearMonth = hitDate.getFullYear + MonthLeading0 + hitMonth; var Year_Month_Day = hitDate.getFullYear + '-' + MonthLeading0 + hitMonth + '-' + DayLeading0 + hitDay;

hitDate.setDate(hitDate.getDate - 30); //form dates for prev month; var hitMonth = hitDate.getMonth+1; //Date counts months from zero; var hitDay = hitDate.getDate; var MonthLeading0 = ''; if (hitMonth < 10) {MonthLeading0 = '0';} else {MonthLeading0 = '';} var DayLeading0 = ''; if (hitDay < 10) {DayLeading0 = '0';} else {DayLeading0 = '';}

var Year_PrevMonth_Day = hitDate.getFullYear + '-' + MonthLeading0 + hitMonth + '-' + DayLeading0 + hitDay;

// utility function

//Add sidebar menu function ('User:Anakin101/addPortlet.js') function addPortlet(id, title, before) { var copy = document.getElementById('p-tb'); var div = document.createElement('div'); div.setAttribute('id', id); div.setAttribute('class', copy.getAttribute('class')); div.innerHTML = ' ' + title + ' '; var pBody = document.createElement('div'); pBody.setAttribute('class', copy.getElementsByTagName('div')[0].getAttribute('class')); pBody.appendChild(document.createElement('ul')); div.appendChild(pBody); if (before && (before = document.getElementById(before))) { copy.parentNode.insertBefore(div, before); } else { copy.parentNode.appendChild(div); }	return pBody; } //end sidebar menu function

//navigation menu

$.when( mw.loader.using( [ 'mediawiki.util'] ), $.ready ).done( function { //Work in progress  mw.util.addPortletLink('p-navigation', 'http://en.wikipedia.org/wiki/User:Spinningspark/Work_in_progress', 'Work in progress', 'n-wip', 'Work in progress page', , );  //Maintenance templates  mw.util.addPortletLink('p-navigation', 'http://en.wikipedia.org/wiki/Wikipedia:Template_messages', 'Maintenance templates', 'n-usertemp', 'Maintenance templates', , );  mw.util.addPortletLink('p-navigation', 'http://en.wikipedia.org/wiki/User:Spinningspark/Useful_templates', 'My useful templates', 'n-mytemp', 'My useful templates', , );  mw.util.addPortletLink('p-navigation', 'http://en.wikipedia.org/wiki/Template:HD', 'Helpdesk templates', 'n-hd', 'Helpdesk templates', , ); });

//end navigation menu

//personal menu

//Coding and formatting $.when( mw.loader.using( [ 'mediawiki.util'] ), $.ready ).done( function {  mw.util.addPortletLink('p-personal', 'http://en.wikipedia.org/wiki/User:Spinningspark/Coding_and_formatting', 'Coding help', 'pt-coding', 'Go to Coding and formatting page', '', document.getElementById('pt-logout')); });

//end personal menu

//content action tabs

//Is X an admin? if( uservar) { $.when( mw.loader.using( [ 'mediawiki.util'] ), $.ready ).done( function {	    mw.util.addPortletLink('p-cactions', 'http://en.wikipedia.org/w/index.php?title=Special:ListUsers&limit=1&username='+ encodeURIComponent( uservar), 'Admin?', 'ca-admin', 'Determine if user is an admin', , );	    }); }

//end content action tabs

//interaction menu //The name of this portlet is 'p-interaction' if user addition required in future //end interaction menu

//toolbox additional tools

$.when( mw.loader.using( [ 'mediawiki.util'] ), $.ready ).done( function { mw.util.addPortletLink('p-tb', 'http://en.wikipedia.org/wiki/Special:Upload', 'Upload form', 't-upload_form', 'Go direct to upload form', '', document.getElementById('t-upload'));

mw.util.addPortletLink('p-tb', 'https://en.wikipedia.org/wiki/User:Spinningspark/Useful_tools', 'More tools', 't-more', 'Other useful tools', , );

});

//end toolbox additional tools

//Toolbox 2 Administration tools $.when( mw.loader.using( [ 'mediawiki.util'] ), $.ready ).done( function { addPortlet('p-tb2', 'Admin tools', 'p-coll-print_export');

//Block user if ( mw.config.get( 'wgNamespaceNumber' ) === 3 || mw.config.get( 'wgNamespaceNumber' ) === 2 ) { mw.util.addPortletLink('p-tb2', '/wiki/Special:Block/'+uservar, 'Block user', 't-block', 'Block user', , ); }

//Wikiblame mw.util.addPortletLink('p-tb2', 'http://wikipedia.ramselehof.de/wikiblame.php?article='+ encodeURIComponent(mw.config.get( 'wgPageName')), 'Wikiblame', 't-wikiblame', 'Go to Wikiblame tool', , );

//User contribution search mw.util.addPortletLink('p-tb2', 'http://tools.wmflabs.org/usersearch/usersearch.py?name=Spinningspark&page='+encodeURIComponent(mw.config.get( 'wgPageName'))+'&server=enwiki&max=500', 'Contribs search', 't-contribsearch', 'Find user contributions on this page', , );

//Watchers mw.util.addPortletLink('p-tb2', 'https://en.wikipedia.org/w/index.php?title='+encodeURIComponent(mw.config.get( 'wgPageName'))+'&action=info#mw-pageinfo-watchers', 'Watchers', 't-watchers', 'Numbers watching this page', , );

//Active watchers mw.util.addPortletLink('p-tb2', 'http://toolserver.org/~dispenser/cgi-bin/watcher.py?page='+encodeURIComponent(mw.config.get( 'wgPageName')), 'Active watchers', 't-awatchers', 'Numbers watching this page', , );

//Unified login information if(uservar){ mw.util.addPortletLink('p-tb2', 'http://toolserver.org/~quentinv57/sulinfo/'+ uservar, 'Unified login', 't-unified_login', 'Unified login statistics', , );

//User autoblock search mw.util.addPortletLink('p-tb2', 'http://tools.wmflabs.org/xtools/autoblock/?u='+ encodeURIComponent(uservar), 'Autoblock search', 't-autoblock_search', 'User autoblock search', , ); }

//CIDR range contributions mw.util.addPortletLink('p-tb2', 'https://tools.wmflabs.org/xtools/rangecontribs/?project=en.wikipedia.org&text='+range16 + '&limit=50&begin=' + Year_PrevMonth_Day, 'CIDR (X!tools)', 't-CIDR_range', 'CIDR range contributions tool', , );

//WikiChecker mw.util.addPortletLink('p-tb2', 'http://en.wikichecker.com/', 'WikiChecker', 't-WikiChecker', 'WikiChecker main page', , );

}); //end toolbox 2

//Toolbox 3: Editing tools $.when( mw.loader.using( [ 'mediawiki.util'] ), $.ready ).done( function { addPortlet('p-tb3', 'Editing tools', 'p-coll-print_export');  //WebCite  mw.util.addPortletLink('p-tb3', 'http://www.webcitation.org/archive', 'WebCite', 't-webcite', 'Web Citation archive tool', , );  //Bugzilla  mw.util.addPortletLink('p-tb3', 'https://bugzilla.wikimedia.org/', 'Bugzilla', 't-bugzilla', 'Bugzilla for MediaWiki', , );  mw.util.addPortletLink('p-tb3', 'https://tools.wmflabs.org/copyvios/?lang=en&project=wikipedia&title='+ encodeURIComponent( mw.config.get( 'wgPageName' ) ) +'&action=search&use_engine=1&use_links=1', 'Copyvio check', 't-copyvio', 'Earwig\'s copyvio tool', , ); }); //end toolbox 3

//Toolbox 4: Statistics $.when( mw.loader.using( [ 'mediawiki.util'] ), $.ready ).done( function { addPortlet('p-tb4', 'Statistics', 'p-coll-print_export');

//User stats tools if( uservar ) { mw.util.addPortletLink('p-tb4', 'http://tools.wmflabs.org/supercount/index.php?user='+ encodeURIComponent( uservar ) +'&project=en.Wikipedia', 'User statistics', 't-user stats', 'User statistics', , ); mw.util.addPortletLink('p-tb4', 'http://en.wikichecker.com/user/?t='+ encodeURIComponent( uservar )+'&l=1000', 'WikiChecker user stats', 't-wcuser stats', 'User statistics', , ); }

//Admin statistics mw.util.addPortletLink('p-tb4', 'https://tools.wmflabs.org/xtools/adminstats/', 'Administrator statistics', 't-adminstats', 'Admin action statistics', , );

//Page editing stats mw.util.addPortletLink('p-tb4', 'http://vs.aka-online.de/cgi-bin/wppagehiststat.pl?page='+ encodeURIComponent( mw.config.get( 'wgPageName' ) ), 'Page editing statistics', 't-pagestats', 'Page statistics', , ); mw.util.addPortletLink('p-tb4', 'http://en.wikichecker.com/article/?a='+ encodeURIComponent( mw.config.get( 'wgPageName' ) ), 'WikiChecker page stats', 't-wcpagestats', 'Page statistics', , );

//Page creation counter mw.util.addPortletLink('p-tb4', 'http://toolserver.org/~tparis/pages/index.php?'+userparam+'lang=en&wiki=wikipedia&namespace=0&redirects=noredirects', 'Page creation counter', 't-pagecreatecount', 'Users page creation count', , );

// Page hit counter mw.util.addPortletLink('p-tb4', 'https://tools.wmflabs.org/pageviews/?project=en.wikipedia.org&start='+Year_PrevMonth_Day+'&end='+Year_Month_Day+'&pages='+ encodeURIComponent( mw.config.get( 'wgPageName' ) ), 'Page hit counter', 't-pagehit', 'Page hit counter', , );

//Ngram viewer mw.util.addPortletLink('p-tb4', 'https://books.google.com/ngrams', 'N-gram viewer', 't-ngram', 'Ngram viewer', , );

//Google correlate statistics mw.util.addPortletLink('p-tb4', 'http://www.google.com/trends/correlate/', 'Correlation statistics', 't-correlation', 'Google correlate', , );

}); //end toolbox 4

//importScript('User:Mr.Z-man/closeAFD2.js'); //Now a gadget //Page size function importScript('User:Dr pda/prosesize.js'); importScript('User:PrimeHunter/Source links.js'); // What links here with transclusions removed importScript('User:Evad37/duplinks-alt.js'); // Find duplicate wikilinks on a page