MediaWiki:KillChatEmoticons/code.2.js

/* * @version 2.0 * @author Clear Arrow * Original: Dorumin * Destroys all the emoticons or the ones you want */ (function($, mw, w) {	'use strict';	if (mw.config.get('wgCanonicalSpecialPageName', '') != 'Chat' || !w.mainRoom) {		return;	}	// Remove the emoticons 	function killAll {		// From the original script		var oldEmotes = Array.prototype.slice.call(document.querySelectorAll('.Chat .message img'));		oldEmotes.forEach(function(el) { el.removeAttribute('src'); });		// Better way to remove the emoticons		mw.config.set('wgChatEmoticons', "");	}	/* 	 * Note: Some things in this function are commented because they make the script behave in a weird way, they will be removed if I don't find a solution	 */	// Kill some emoticons by URL	function killSome {		//var isurl = /https?:\/\//gi,		var toKill = w.emotesKilled,		emotes = mw.config.get('wgChatEmoticons', ""),		list = emotes.split('\n'),		newlist,		alts = [];		for (var i in toKill) {			//if (isurl.test(toKill[i])) {			for (var j in list) {				alts = [];				if (list[j].indexOf(toKill[i]) != -1) {					// Alts					var n = j;					do {						n++;						alts.push(list[n]);					} while (list[n].indexOf("**") != -1);					//console.log(alts); This is to show which are working					list.splice(j, alts.length);				}			}			//}			/*else {					if (a.search(toKill[i] > -1)) {						list.splice(b, 1);					}			}*/ }		newlist = list.join('\n'); mw.config.set('wgChatEmoticons', newlist); }	// Init $(function {		var KillTheEmos = setInterval(function  { try { if (w.mainRoom.isInitialized == true && typeof mw.config.get('wgChatEmoticons', "") == "string" ) { if (Array.isArray(w.emotesKilled)) { killSome; }					else { killAll; }					clearInterval(KillTheEmos); }			}			catch (err) { console.info(err); }		}, 500);	}); })(jQuery, mw, this); //