User:Spinningspark/monobook.js
Jump to navigation
Jump to search
Note – after saving, you may have to bypass your browser’s cache to see the changes.
- Mozilla / Firefox / Safari: hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (Command-R on a Macintosh);
- Konqueror and Chrome: click Reload or press F5;
- Opera: clear the cache in Tools → Preferences;
- Internet Explorer: hold Ctrl while clicking Refresh, or press Ctrl-F5.
- This script lacks a documentation subpage. You may create it.
- Useful links: root page • root page’s subpages • links • redirects • your own
This JavaScript is executed for Spinningspark on every page load, when User:Spinningspark is using the Monobook skin.
//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; }
//end Find username
// Utility functions
//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 = '<h3>' + title + '</h3>';
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
//Toolbox 4: Statistics
$.when( mw.loader.using( [ 'mediawiki.util'] ), $.ready ).done( function() {
addPortlet('p-tb4', 'Statistics', 'p-coll-print_export');
//User stats tool
mw.util.addPortletLink('p-tb4', 'http://toolserver.org/~tparis/pcount/index.php?'+userparam+'lang=en&wiki=wiktionary', 'User statistics', 't-user stats', 'User 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', '', '');
//Page creation counter
mw.util.addPortletLink('p-tb4', 'http://toolserver.org/~tparis/pages/index.php?'+userparam+'lang=en&wiki=wiktionary&namespace=0&redirects=noredirects', 'Page creation counter', 't-pagecreatecount', 'Users page creation count', '', '');
//Page hit counter
var hitdate=new Date();
var hitmonth=hitdate.getMonth()+1 //Date() counts months from zero
var leading0=''
if (hitmonth.length = 1) {leading0 = '0';}
else {leading0 = '';}
mw.util.addPortletLink('p-tb4', 'http://stats.grok.se/en/'+hitdate.getFullYear()+leading0+hitmonth+'/Wiktionary:'+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