User:Flooded with them hundreds/1.js

From Wikipedia, the free encyclopedia
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
// Shorten pt navigation items
$( function () {
	document.getElementById('pt-userpage').getElementsByTagName('a')[0].firstChild.nodeValue = 'Flooded';
	document.getElementById('pt-mytalk').getElementsByTagName('a')[0].firstChild.nodeValue = 'Talk';
	document.getElementById('pt-preferences').getElementsByTagName('a')[0].firstChild.nodeValue = 'Pref';
	document.getElementById('pt-sandbox').getElementsByTagName('a')[0].firstChild.nodeValue = 'Sandbox';
	document.getElementById('pt-watchlist').getElementsByTagName('a')[0].firstChild.nodeValue = 'Watch';
	document.getElementById('pt-mycontris').getElementsByTagName('a')[0].firstChild.nodeValue = 'Contribs';
	document.getElementById('pt-logout').getElementsByTagName('a')[0].firstChild.nodeValue = 'x';
});

// Shortcuts

$.when( mw.loader.using('mediawiki.util'), $.ready ).then( function() {
   mw.util.addPortletLink( 'p-interaction', '/wiki/Category:Pending AfC submissions', 'AfC submissions');
   mw.util.addPortletLink( 'p-interaction', '/wiki/User:AnomieBOT/Edit_requests_table', 'Edit requests');
   mw.util.addPortletLink( 'p-interaction', '/wiki/Special:PendingChanges', 'Pending changes');
   mw.util.addPortletLink ('p-tb', 'http://toolserver.org/~dispenser/cgi-bin/webchecklinks.py/' + encodeURI( mw.config.get( 'wgPageName' ) )
   + '?client=script&citeweb=on&overwrite=&limit=20&lang=' + mw.config.get( 'wgContentLanguage'), 'Checklinks');
   mw.util.addPortletLink ('p-tb', 'http://toolserver.org/~dispenser/cgi-bin/reflinks.py?' + '&page=' + encodeURIComponent( mw.config.get( 'wgPageName' ) ) + '&autoclick=wpPreview', 'Reflinks');
} );

// User highlighter

;mw.hook('wikipage.content').add(function($, mw){
	var ecdata, mvdata, tpdata, addata, budata, cudata, stdata, ovdata;
	$.when(
	$.getJSON(mw.config.get('wgScriptPath')+'/index.php?action=raw&ctype=application/json&title=User:Amorymeltzer/crathighlighter.js/bureaucrat.json', function(data){
		budata = data;
	}),
	$.getJSON(mw.config.get('wgScriptPath')+'/index.php?action=raw&ctype=application/json&title=User:Amorymeltzer/crathighlighter.js/checkuser.json', function(data){
		cudata = data;
	}),
	$.getJSON(mw.config.get('wgScriptPath')+'/index.php?action=raw&ctype=application/json&title=User:Amorymeltzer/crathighlighter.js/steward.json', function(data){
		stdata = data;
	}),
	$.getJSON(mw.config.get('wgScriptPath')+'/index.php?action=raw&ctype=application/json&title=User:Amorymeltzer/crathighlighter.js/oversight.json', function(data){
		ovdata = data;
	}),
	$.getJSON(mw.config.get('wgScriptPath')+'/index.php?action=raw&ctype=application/json&title=User:Bellezzasolo Bot/userhighlighter.js/excon.js', function(data){
		ecdata = data;
	}),
	$.getJSON(mw.config.get('wgScriptPath')+'/index.php?action=raw&ctype=application/json&title=User:Bellezzasolo Bot/userhighlighter.js/pgmvr.js', function(data){
		mvdata = data;
	}),
	$.getJSON(mw.config.get('wgScriptPath')+'/index.php?action=raw&ctype=application/json&title=User:Bellezzasolo Bot/userhighlighter.js/temop.js', function(data){
		tpdata = data;
	}),
	$.getJSON(mw.config.get('wgScriptPath')+'/index.php?action=raw&ctype=application/json&title=User:Amalthea_(bot)/userhighlighter.js/sysop.js', function(data){
		addata = data;
	})
	).then(function() {
	ADMINHIGHLIGHT_EXTLINKS = window.ADMINHIGHLIGHT_EXTLINKS || false;
	ADMINHIGHLIGHT_NAMESPACES = [-1,2,3];
	mw.loader.using(['mediawiki.util','mediawiki.Uri', 'mediawiki.Title'], function() {
		mw.util.addCSS(".userhighlighter_check.userhighlighter_check {background-color: #bbc4f7 !important}");
		mw.util.addCSS(".userhighlighter_overs.userhighlighter_overs {background-color: #91f7bf !important}");
		mw.util.addCSS(".userhighlighter_bureu.userhighlighter_bureu {background-color: #c0a0ff !important}");
		mw.util.addCSS(".userhighlighter_sysop.userhighlighter_sysop {background-color: #96e8ff !important}");
		mw.util.addCSS(".userhighlighter_stewd.userhighlighter_stewd {background-color: #ffb2d2 !important}");
		mw.util.addCSS(".userhighlighter_temop.userhighlighter_temop {background-color: #cecece !important}");
		mw.util.addCSS(".userhighlighter_pgmvr.userhighlighter_pgmvr {background-color: #d789ff !important}");
		mw.util.addCSS(".userhighlighter_excon.userhighlighter_excon {background-color: #87ff7a !important}");
		$('#article a, #bodyContent a, #mw_contentholder a').each(function(index,linkraw){
			try {
				var link = $(linkraw);
				var url = link.attr('href');
				if (!url || url.charAt(0) === '#') return; // Skip <a> elements that aren't actually links; skip anchors
				if (url.lastIndexOf("http://", 0) != 0 && url.lastIndexOf("https://", 0) != 0 && url.lastIndexOf("/", 0) != 0) return; //require http(s) links, avoid "javascript:..." etc. which mw.Uri does not support
				var uri = new mw.Uri(url);
				if (!ADMINHIGHLIGHT_EXTLINKS && !$.isEmptyObject(uri.query)) return; // Skip links with query strings if highlighting external links is disabled
				if (uri.host == 'en.wikipedia.org') {
					var mwtitle = new mw.Title(mw.util.getParamValue('title',url) || decodeURIComponent(uri.path.slice(6))); // Try to get the title parameter of URL; if not available, remove '/wiki/' and use that
					if ($.inArray(mwtitle.getNamespaceId(), ADMINHIGHLIGHT_NAMESPACES)>=0) {
						var user = mwtitle.getMain().replace(/_/g," ");
						if (mwtitle.getNamespaceId() === -1) user = user.replace('Contributions/',''); // For special page "Contributions/<username>"
						if (cudata[user] == 1) {
							link.attr("class", "userhighlighter_check"); // Override the above color by using `a.userhighlighter_sysop.userhighlighter_sysop {background-color: COLOR !important}`
						}
						else if(ovdata[user] == 1) {
							link.attr("class", "userhighlighter_overs"); // Override the above color by using `a.userhighlighter_temop.userhighlighter_temop {background-color: COLOR !important}`
						}
						else if(budata[user] == 1) {
							link.attr("class", "userhighlighter_bureu"); // Override the above color by using `a.userhighlighter_temop.userhighlighter_temop {background-color: COLOR !important}`
						}
						else if(addata[user] == 1) {
							link.attr("class", "userhighlighter_sysop"); // Override the above color by using `a.userhighlighter_temop.userhighlighter_temop {background-color: COLOR !important}`
						}
						else if(stdata[user] == 1) {
							link.attr("class", "userhighlighter_stewd"); // Override the above color by using `a.userhighlighter_temop.userhighlighter_temop {background-color: COLOR !important}`
						}
						else if(tpdata[user] == 1) {
							link.attr("class", "userhighlighter_temop"); // Override the above color by using `a.userhighlighter_temop.userhighlighter_temop {background-color: COLOR !important}`
						}
						else if(mvdata[user] == 1) {
							link.attr("class", "userhighlighter_pgmvr"); // Override the above color by using `a.userhighlighter_pgmvr.userhighlighter_pgmvr {background-color: COLOR !important}`
						}
						else if(ecdata[user] == 1) {
							link.attr("class", "userhighlighter_excon"); // Override the above color by using `a.userhighlighter_excon.userhighlighter_excon {background-color: COLOR !important}`
						}
					}
				}
			} catch (e) {
				// Sometimes we will run into unparsable links, so just log these and move on
				window.console && console.error('Admin highlighter recoverable error',e.message);
			}
		});
	});
	});
}(jQuery, mediaWiki));