MediaWiki:Gadget-adminHighlight.js

From Terraria Mods Wiki
Jump to navigation Jump to search

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.
// load the list of admins on this wiki
// the prefix for the JSON page is 'MediaWiki:Gadget-'
var adminList = require('./adminHighlight-adminList.json').adminlist;

$(document).ready(function() {
	var admins = [];
	for (var i = 0; i < adminList.length; i++) {
		admins.push('User:' + adminList[i]);  // existent user page
		admins.push('User:' + adminList[i] + ' (page does not exist)');  // nonexistent user page
	}
	mw.hook('wikipage.content').add(function() {
		// for each link with a title attribute:
		$('#mw-content-text a[title]').each(function() {
			var $this = $(this);
			var thisuser = $this.attr('title');
			// check if the title attribute is in the list of admins
			if (!$this.hasClass('admin-highlight') && $.inArray(thisuser, admins) > -1) {
				$this.addClass('admin-highlight');
			}
		});
	});
});