User:Randomfvideos/Messageblocker.js

// Author: User:Dyzlon

if (mw.config.get('wgCanonicalSpecialPageName') === 'Chat') { function removeFromArray(x, y){for(i=0;i<x.length;++i){if(x[i]===y){;x.splice(i,1);break; }}} ; function in_array(needle, haystack, argStrict) { ;var key = '', strict = !! argStrict; if (strict) { for (key in haystack) { if (haystack[key] === needle) { return true; } } } else { for (key in haystack) { if (haystack[key] == needle) { ;return true; } } } ;return false; } $(function {        "use strict";blockees=new Array;

function createUl(blockee) { var isBlocked = in_array(blockee, blockees); if (isBlocked === false) { // $('.regular-actions').after('  Block Messages  '); } else { $('.regular-actions').after('  Allow Messages  '); }                $("li.ignore").click(function { ignore(blockee); }); }

function ignore(blockee) { var blockStyle; var blockee = blockee; var isBlocked = in_array(blockee, blockees); if (isBlocked === false) { blockees[blockees.length]=blockee; $("li.ignore").addClass("blue"); blockStyle = document.createElement("style"); blockStyle.innerHTML = ("li[data-user='"+blockee+"']:not(.User){display: none;}"); blockStyle.setAttribute("id", "blockStyle-"+blockee); document.head.appendChild(blockStyle); $("#WikiChatList>li[data-user='"+blockee+"']").addClass("blockee"); $(".UserStatsMenu li.ignore>span.label").replaceWith(" Allow Messages "); } else { removeFromArray(blockees, blockee); $("li.ignore").removeClass("blue"); blockStyle = document.getElementById("blockStyle-"+blockee); blockStyle.parentNode.removeChild(blockStyle); $("#WikiChatList>li[data-user='"+blockee+"']").removeClass("blockee"); $(".UserStatsMenu li.ignore>span.label").replaceWith(" Block Messages ");

}        }

function createUlCall { var blockee = $(this).attr('data-user'); setTimeout(function { createUl(blockee); }, 0); }

$("#WikiChatList").on("click", "li.User", createUlCall);

var messageBlockerStyle = document.createElement("style"); messageBlockerStyle.innerHTML = ".UserStatsMenu .actions li.ignore .icon { background-image: url('http://images.wikia.com/dzy/images/8/81/Sprite-chat-ignore.png');  } .UserStatsMenu .actions li.ignore .icon { background-position: -0px 0; } .UserStatsMenu .actions li.ignore:hover .icon { background-position: -31px 0; } .UserStatsMenu .actions li.ignore.blue .icon { background-position: -67px 0; } .UserStatsMenu .actions li.ignore.blue:hover .icon { background-position: -98px 0; } #WikiChatList>li.blockee { background: #FFE6D8; !important } #WikiChatList>li.away.blockee { background: #FFE6D8; !important } .ignore span.label { position: relative; bottom: 5px; left: 3px; }"; document.head.appendChild(messageBlockerStyle); }); }