User:PooseUnpoose/global.js

/* Monchomans chat hacks */ importScriptPage('User:Monchoman45/ChatHacks.js', 'c'); /* PMs button */ if(wgCanonicalSpecialPageName == 'Chat') { function createGroupPM { var users = prompt('Enter comma seperated list of users to start a PM with',''); var users = users.split(','); mainRoom.openPrivateChat(users); } $('form#Write').append('PM'); } /* Multi kick */ function showPopup { $('body').append(' Mass-kick   Enter usernames here, separated by a comma and a space. Tab insert works.  Kick! Cancel  '); $('body').append(' '); } function kickUsers { var multikick = $('#multikickinput').val if (multikick.length != 0) { var usersToKick = multikick.split(", "); var i = 0; for (i; iMultikick').appendTo('.Write'); //Tab insert for usernames //Written by Joeytje50 of Runescape wiki function getCaretPos(ctrl) { var CaretPos = 0;   // IE Support if (document.selection) { ctrl.focus ; var Sel = document.selection.createRange ; Sel.moveStart ('character', -ctrl.value.length); CaretPos = Sel.text.length; }   // Firefox support else if (ctrl.selectionStart || ctrl.selectionStart == '0') CaretPos = ctrl.selectionStart; return (CaretPos); } function setCaretPos(ctrl, pos){ if(ctrl.setSelectionRange) {       ctrl.focus; ctrl.setSelectionRange(pos,pos); }   else if (ctrl.createTextRange) { var range = ctrl.createTextRange; range.collapse(true); range.moveEnd('character', pos); range.moveStart('character', pos); range.select; } } $('#multikickinput').after(' [0,"","",0,null] '); $('#multikickinput').keydown(function(e) {	if (e.keyCode == 9) {		e.preventDefault;		var curval = this.value;		var afData = eval(document.getElementById('autofilldata').innerHTML);		var curpos = afData[3]==0?getCaretPos(this):afData[3];		var carpos = getCaretPos(this)		if ((!curval.charAt(carpos)||curval.charAt(carpos).match(/\s/))&&!curval.charAt(carpos-1).match(/\s/)&&this.value.length) {			var unamestart = ;			if (afData[1].length==0) {				for (i=curpos-1;i>=0&&!curval.charAt(i).match(/\s/);i--) {					unamestart = curval.charAt(i) + unamestart;				}			} else {				unamestart = afData[1];			}			var afterTComplete = ;			for (i=curpos;i<curval.length;i++) {				afterTComplete += curval.charAt(i);			}			//generate list of users			var userList = '';			var userlistelems = document.getElementsByClassName('User');			for (i=0;i=0&&i>=carpos-(!(afData[4]===null)?(matchedNames[afData[4]]?matchedNames[afData[4]].length:0) : unamestart.length)&&matchedNames.length>0;i--) { newval[i] = ''; }			matchedNames = !matchedNames[0]?['']:matchedNames; newval[curpos-unamestart.length] += matchedNames[afData[0]]?matchedNames[afData[0]]:''; newval = newval.join(''); this.value = newval; setCaretPos(this, curpos+(matchedNames[afData[0]].length?matchedNames[afData[0]].length:0)) var iter = afData[0]>=matchedNames.length-1?0:afData[0]+1; document.getElementById('autofilldata').innerHTML = '['+iter+',"'+unamestart+'","'+matchedNames[afData[0]]+'",'+curpos+','+afData[0]+']' }		return false; } else if (e.which != 16) { document.getElementById('autofilldata').innerHTML = '[0,"","",0,null]'; } }).click(function { document.getElementById('autofilldata').innerHTML = '[0,"","",0,null]'; }).blur(function { document.getElementById('autofilldata').innerHTML = '[0,"","",0,null]'; }) /* Chat options */ var chatOptionsLoaded; if (chatOptionsLoaded != 1){ chatOptionsLoaded = 1; importScriptPage('MediaWiki:Chat.js/options.js','cod'); } /* Block Chat Messages */ if (mw.config.get('wgPageName') === 'Special:Chat') {   $(function  { "use strict"; function createUl(blockee) { var isBlocked = $("#WikiChatList>li[data-user='"+blockee+"']").hasClass("blockee"); if (isBlocked === false) { $('.regular-actions').after(' <ul> Block Messages </li></ul>'); } else { $('.regular-actions').after(' <ul> Allow Messages </li></ul>'); }	           $("li.ignore").click(function { ignore(blockee); }); }       function ignore(blockee) { var blockStyle; var blockee = blockee; var isBlocked = $("#WikiChatList>li[data-user='"+blockee+"']").hasClass("blockee"); var isMod = $("#WikiChatList>li[data-user='"+blockee+"']").hasClass("chat-mod"); if (isMod === false) { if (isBlocked === false) { $("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 { $("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 "); }           } else { var lastMsg = $('.Chat>ul>li:last-child'); var lastMsgIsAlert = lastMsg.hasClass("inline-alert"); if (lastMsgIsAlert === true) { lastMsg.after("<li class='inline-alert continued' style='color:red'>You cannot block chat moderators, administrators, or Wikia staff members.</li>"); } else { lastMsg.after("<li class='inline-alert' style='color:red'>You cannot block chat moderators, administrators, or Wikia staff members.</li>"); }           }        }        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 } .ignore span.label { position: relative; bottom: 5px; left: 3px; }"; document.head.appendChild(messageBlockerStyle); }); } //