User:Mikevoir/global.js

importArticles({   type: 'script',    articles: [        'u:dev:MediaWiki:AjaxBatchDelete.js',        'u:dev:MediaWiki:Bang.js',        'u:dev:MediaWiki:FileUsageAuto-update/code.js',        'u:dev:MediaWiki:LastEdited/code.js',        'u:dev:MediaWiki:MassRename/code.js',        'u:dev:MediaWiki:MassNullEdit/code.js',        'u:dev:MediaWiki:PurgeButton.js',        'u:dev:MediaWiki:Wikimarks/code.js',    ] });

// No thanks document.querySelectorAll('.mw-thanks-thank-link').forEach(function(el) {	if (el.parentNode.nodeName === 'SPAN'){		el.parentNode.remove;	}else{		if ( el.previousSibling.data === '( ' && el.nextSibling.data === ' )' ) {			el.nextSibling.remove;			el.previousSibling.remove;		}		el.remove;	} });

// Make RC properly give links on diffs that include page creations var properLinks = { init: function { this.api = new mw.Api; this.pages; },	pages: function { var api = this.api; document.querySelectorAll('.mw-changeslist-links > span:first-child').forEach(		  	function(el) {				if (el.childNodes.length === 1 && el.childElementCount === 0){					var pageName = el.parentNode.parentNode.parentNode.getElementsByClassName('mw-changeslist-title')[0].attributes.title.nodeValue;					while (el.firstChild) {					  el.removeChild(el.firstChild);					}					api.get({ action: 'query', titles: pageName, meta: 'tokens', prop: 'revisions', rvprop: 'ids|timestamp|user|userid|size|parsedcomment|flags', rvlimit: 1000, formatversion: 2 }).then(function(data) { var link = document.createElement('a'); var page = data.query.pages[0].title;

var revisions = data.query.pages[0].revisions; var from = revisions[revisions.length-1].revid; var to = revisions[0].revid; if (from === to) { from = 0; }

var label = 'diff'; if (revisions.length>1) { label = revisions.length + ' changes'; link.classList.add('mw-changeslist-diff'); } else { link.classList.add('mw-changeslist-groupdiff'); }

link.href = '/wiki/'+page+'?diff='+ to +'&oldid='+from; link.title = page; link.appendChild(document.createTextNode(label)); el.appendChild(link); });				}			}		);	},	build: function(data) {

} }; mw.loader.using([   'mediawiki.api',    'mediawiki.util',    (mw.config.get('isGamepedia') ? 'jquery.timeago' : 'jquery') ]).then(function {	$($.proxy(properLinks.init, properLinks)); });