User:L10nM4st3r/global.js

From Meta, a Wikimedia project coordination wiki

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
mw.loader.load('//meta.wikimedia.org/w/index.php?title=User:Xiplus/TwinkleGlobal/load.js&action=raw&ctype=text/javascript');
mw.loader.load('//en.wikibooks.org/w/index.php?title=User:L10nM4st3r/ReportUser/Beta.js&action=raw&ctype=text/javascript');

$.when($.ready,mw.loader.using(['mediawiki.util'])).then( function(){
	// Add link to show unreviewed recent changes to personal links
	mw.util.addPortletLink("p-personal", mw.config.get('wgServer')+"/w/index.php?hidemyself=1&hidepreviousrevisions=1&hideWikibase=1&hidelog=1&hidenewuserlog=1&flaggedrevs=needreview&limit=50&days=7&flaggedrevs__needreview_color=c3&title=Special:RecentChanges&urlversion=2", "Recent Changes", "pt-rc", "Show unreviewed recent changes");
	// Optimized live UTC clock
	var node=mw.util.addPortletLink('p-personal','','','utcdate',"Press to purge the cache of the page");
	if(!node)return;
	$(node).on('click',function(e){
		new mw.Api().post({action:'purge',titles:mw.config.get('wgPageName')}).then(function(){location.reload();},function(){mw.notify('Purge failed',{type:'error'});});
		e.preventDefault();
	});
	showTime($(node).find('a:first'));
});

function padWithZeroes(num){return num < 10 ? '0' + num.toString() : num.toString();}

function showTime( $target ) {
	var now = new Date();
	// Set the time.
	var hh, mm, ss;
	hh = now.getUTCHours();
	mm = now.getUTCMinutes();
	ss = now.getUTCSeconds();
	var time = padWithZeroes( hh ) + ':' + padWithZeroes( mm ) + ':' + padWithZeroes( ss );
	$target.text( time );
	setTimeout( function () {
		showTime( $target );
	}, 1005);
}

mw.loader.load('https://en.wikipedia.org/w/load.php?modules=ext.gadget.Navigation_popups');