User:Chrs/global.js

From Miraheze Meta, Miraheze's central 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.
var global_signature = "—&nbsp;<span style=\"font-variant: small-caps\">[[User:Chrs|Chrs]] ([[User talk:Chrs|talk]])</span>"

$( document ).ready( function() {
	if(mw.config.get('wgRelevantUserName') != null) {
		mw.util.addPortletLink(
			'p-tb',
			'https://meta.miraheze.org/wiki/Special:RequestWikiQueue?status=*&requester=' + mw.config.get('wgRelevantUserName'),
			'Wiki requests',
			't-wikireq',
			'List wiki requests by user',
			'',
			'#t-upload'
		);
		mw.util.addPortletLink(
			'p-tb',
			'https://meta.miraheze.org/wiki/Special:RequestImportDumpQueue?status=*&requester=' + mw.config.get('wgRelevantUserName'),
			'Import requests',
			't-importreq',
			'List import requests by user',
			'',
			'#t-upload'
		);
	}
	
	mw.util.addPortletLink(
		'p-tb',
		location.href.replace( location.hash, '' ) + ( location.search ? '&' : '?' ) + 'uselang=qqx',
		'Interface debug',
		't-ifdebug',
		'Reload the current page with message id\'s displayed instead of text'
	);
	
	mw.util.addPortletLink(
		'p-tb',
		'/wiki/Special:AbuseFilter',
		'Abuse filter',
		't-abfilter',
		'Open the abuse filter management interface'
	);
  
	$('.mw-usertoollinks .mw-usertoollinks-contribs').each(function(){
		$(this).after(' | <a href="https://meta.miraheze.org/wiki/Special:CentralAuth/' + encodeURIComponent($(this).prop('title').match(/Special:Contributions\/(.*)/)[1]) + '">global</a>')
	})
	
	if(mw.config.get('wgCanonicalSpecialPageName') == 'Contributions'){
		$('.mw-contributions-user-tools .mw-changeslist-links').append('<span><a href="https://meta.miraheze.org/wiki/Special:CentralAuth/' + encodeURIComponent(mw.config.get('wgRelevantUserName')) + '">global</a></span>')
	}
});

mw.hook('moremenu.ready').add(function () {
	if (!mw.config.get( 'wgIsArticle' )) return;
	$('#mm-page-purge-cache').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();
	});
	$('#mm-page-purge-cache-link').on( 'click', function (e) {
		new mw.Api().post( { action: 'purge', forcelinkupdate: true, forcerecursivelinkupdate: true, titles: mw.config.get( 'wgPageName' ) } ).then(function () {
			location.reload();
		}, function () {
			mw.notify( 'Purge failed', { type: 'error' } );
		});
		e.preventDefault();
	});
});

mw.loader.load('https://en.wikipedia.org/w/index.php?action=raw&ctype=text/javascript&title=MediaWiki:Gadget-markblocked.js');
mw.loader.load('https://en.wikipedia.org/w/index.php?action=raw&ctype=text/javascript&title=User:Gary/comments_in_local_time.js');
mw.loader.load('https://commons.wikimedia.org/w/index.php?action=raw&ctype=text/javascript&title=MediaWiki:Gadget-HotCat.js');
mw.loader.load('https://en.wikipedia.org/w/index.php?action=raw&ctype=text/javascript&title=User:BrandonXLF/Restorer.js');

mw.loader.using(['mediawiki.user', 'mediawiki.util', 'mediawiki.api'], function () {
    mw.loader.load('https://meta.miraheze.org/w/index.php?action=raw&ctype=text/javascript&title=User:Chrs/MoreMenu.js');
    if(mw.user.options.values['nickname'] != global_signature){
		new mw.Api().postWithToken('csrf', {
			action: 'options',
			change: 'fancysig=1',
			optionname: 'nickname',
			optionvalue: global_signature
		});
	}
});