MediaWiki:Chat.js

/*function chatNotificationButton{"enabled"==getCookie(wikiCookieName+"_ChatNotification")?chatDisableNotification:("disabled"==getCookie(wikiCookieName+"_ChatNotification")||null===getCookie(wikiCookieName+"_ChatNotification"))&&chatEnableNotification}function chatPingButton{"enabled"==getCookie(wikiCookieName+"_ChatPing")?chatDisablePing:("disabled"==getCookie(wikiCookieName+"_ChatPing")||null===getCookie(wikiCookieName+"_ChatPing"))&&chatEnablePing}function chatEnableNotification{"undefined"!=typeof Notification&&Notification.permission?"default"==Notification.permission||"denied"==Notification.permission?Notification.requestPermission(function{chatEnableNotification}):"granted"==Notification.permission&&($(document.head).append('.UserStatsMenu .new-actions .chatEnableNotification .icon {background-position:-180px 0px !important;} .UserStatsMenu .new-actions .chatEnableNotification:hover .icon {background-position:-211px 0px !important;} '),setCookie(wikiCookieName+"_ChatNotification","enabled",36500)):"undefined"!=typeof webkitNotifications&&webkitNotifications.checkPermission&&(1==webkitNotifications.checkPermission||2==webkitNotifications.checkPermission?Notification.requestPermission(function{chatEnableNotification}):0===webkitNotifications.checkPermission&&($(document.head).append('.UserStatsMenu .new-actions .chatEnableNotification .icon {background-position:-180px 0px !important;} .UserStatsMenu .new-actions .chatEnableNotification:hover .icon {background-position:-211px 0px !important;} '),setCookie(wikiCookieName+"_ChatNotification","enabled",36500)))}function chatDisableNotification{$("style#chatNotificationEnabled").remove,setCookie(wikiCookieName+"_ChatNotification","disabled",36500)}function chatEnablePing{$(document.head).append('.UserStatsMenu .new-actions .chatEnablePing .icon {background-position:-180px 0px !important;} .UserStatsMenu .new-actions .chatEnablePing:hover .icon {background-position:-211px 0px !important;} '),setCookie(wikiCookieName+"_ChatPing","enabled",36500)}function chatDisablePing{$("style#chatPingEnabled").remove,setCookie(wikiCookieName+"_ChatPing","disabled",36500)}function chatSendNotification{chatMsgCharCheck,chatMsgNotification}function chatMsgCharCheck{chatShortMsg=$(".Chat:first li:not('.Chat:first .you, .Chat:first .inline-alert'):last .message").html.length>26?" ...":""}function chatMsgNotification{var a=new Notification(wgSiteName+" Chat:",{dir:"auto",body:$(".Chat:first li:not('.Chat:first .you, .Chat:first .inline-alert'):last .username").html.split(" <img")[0]+": "+$(".Chat:first li:not('.Chat:first .you, .Chat:first .inline-alert'):last .message").html.substring(0,26).replace(/\s+/g," ")+chatShortMsg,tag:$(".Chat:first li:not('.Chat:first .you, .Chat:first .inline-alert'):last").attr("id"),icon:$(".Chat:first li:not('.Chat:first .you, .Chat:first .inline-alert'):last .avatar").attr("src").replace("28px","150px")});a.onclick=function{window.focus},a.onshow=function{setTimeout(function{a.close},5e3)}}function chatPlayPing{chatMsgSound}function chatMsgSound{$("body").append(" "),document.getElementById("newmsgsound").volume=1,document.getElementById("newmsgsound").play,window.setTimeout(function{$("#newmsgsound").remove},500)}function chatCheckFocus{chatFocused?chatUPDchatNumMsg:chatCheckForNewMsg}function chatUPDchatNumMsg{chatNumMsg=$(".Chat:first li").not(".you, .inline-alert").length}function chatCheckForNewMsg{chatMsgNumCheck}function chatMsgNumCheck{$(".Chat:first li").not(".you, .inline-alert").length>chatNumMsg&&chatNewMsg}function chatNewMsg{chatUPDchatNumMsg,"enabled"==getCookie(wikiCookieName+"_ChatNotification")&&"enabled"==getCookie(wikiCookieName+"_ChatPing")?(chatPlayPing,chatSendNotification):"enabled"==getCookie(wikiCookieName+"_ChatNotification")?chatSendNotification:"enabled"==getCookie(wikiCookieName+"_ChatPing")&&chatPlayPing}function chatSidebarPrependYou{$(".Rail .WikiChatList").prepend($('.Rail .WikiChatList li[data-user="'+wgUserName+'"]')),chatSidebarYouAddClass}function chatSidebarYouAddClass{$('.Rail .WikiChatList li[data-user="'+wgUserName+'"]').addClass("you"),chatSidebarRemOldActions}function chatSidebarRemOldActions{$(".UserStatsMenu .actions .new-actions").parent.find("ul, hr").not(".new-actions, .new-actions hr").remove,chatSidebarAddHTML}function chatSidebarAddHTML{$('.Rail .WikiChatList li[data-user="'+wgUserName+'"] .UserStatsMenu .actions').html(' Talk Page   Contributions   Notifications  Beep On Received Message </ul>'),chatCheckForHacks}function chatCheckForHacks{$('.Write .wikia-button[href="javascript:createGroupPM"]').length>=1&&$('.Rail .WikiChatList li[data-user="'+wgUserName+'"] .UserStatsMenu .new-actions').append(' Start Group Chat </li>'),$('.Write .wikia-button[href="javascript:toggleAway"]').length>=1&&$('.Rail .WikiChatList li[data-user="'+wgUserName+'"] .UserStatsMenu .new-actions').append(' Toggle Away Status </li>'),$('.Write .wikia-button[href="javascript:active.clearWindow"]').length>=1&&$('.Rail .WikiChatList li[data-user="'+wgUserName+'"] .UserStatsMenu .new-actions').append(' Clear Chat </li>')}function setCookie(a,b,c){var d=new Date;d.setDate(d.getDate+c);var e=escape(b)+(null===c?"":"; expires="+d.toUTCString);document.cookie=a+"="+e}function getCookie(a){var b=document.cookie,c=b.indexOf(" "+a+"=");if(-1==c&&(c=b.indexOf(a+"=")),-1==c)b=null;else{c=b.indexOf("=",c)+1;var d=b.indexOf(";",c);-1==d&&(d=b.length),b=unescape(b.substring(c,d))}return b}function chatGetRoomId{return 1==$(".WikiaPage .Chat:visible").length?$(".WikiaPage .Chat:visible").attr("id").replace(/Chat_/,""):void 0}function chatSubmitButtonSendMsg{"undefined"==typeof NodeChatController.prototype.chats.privates[chatGetRoomId]?chatGetRoomId==mainRoom.roomId&&(mainRoom.socket.send(new models.ChatEntry({roomId:chatGetRoomId,name:wgUserName,text:mainRoom.viewDiscussion.getTextInput.val}).xport),mainRoom.viewDiscussion.getTextInput.val("")):(NodeChatController.prototype.chats.privates[chatGetRoomId].socket.send(new models.ChatEntry({roomId:chatGetRoomId,name:wgUserName,text:mainRoom.viewDiscussion.getTextInput.val}).xport),mainRoom.viewDiscussion.getTextInput.val(""))}var chatFocused=!0;window.onfocus=function{chatFocused=!0},window.onblur=function{chatFocused=!1};var wikiCookieName="LMOWiki";"enabled"==getCookie(wikiCookieName+"_ChatNotification")&&chatEnableNotification,"enabled"==getCookie(wikiCookieName+"_ChatPing")&&chatEnablePing;var chatShortMsg="",chatNumMsg=$(".Chat:first li").not(".you, .inline-alert").length,chatMsgCheckInterval=setInterval(function{chatCheckFocus},1e3),chatSidebarYouInterval=setInterval(function{chatSidebarPrependYou},1e3);$("head").append('<meta name="viewport" content="width=device-width, initial-scale=1"> '),$('.Write input[type="submit"]').attr("value","Send"),$('.Write input[type="submit"]').click(function{mainRoom.viewDiscussion.getTextInput.val.length>0&&chatSubmitButtonSendMsg}),$("#Rail .wordmark .chevron").click(function{$("body").width<768&&($("#Rail .wordmark .chevron.closed").length>0?$("#Rail .private, .PrivateChatList").css("display","none"):$("#Rail .private, .PrivateChatList").css("display","block"))}),$("body").width<768&&($("#Rail .wordmark .chevron").not(".closed").click,$("#Rail .wordmark .chevron").click(function(a){a.stopPropagation}),$("#Rail .wordmark.selected").click(function{$("#Rail .wordmark.selected .chevron").click}),$("#Rail .wordmark").not(".selected").click(function{$("#Rail .wordmark .chevron").not(".closed").click}),$("#PrivateChatList").on("click",".User:not(.selected)",function{$("#Rail .wordmark .chevron").not(".closed").click})),$('.wordmark img[width="115"][height="30"]').attr("src","https://images.wikia.nocookie.net/legominifiguresonline/images/thumb/8/89/Wiki-wordmark.png/130px-Wiki-wordmark.png"); // *************** // Spam protection // *************** // Credit to Joeytje50, script modified slightly for more leniency/easier changing // Change these variables to modify the leniency of the script var maxLimit = 6; // limit for sent lines var maxLength = 1250; // limit for how long a line can be (in chars) var limitTimeout = 2000; // timeout for the sent lines limiter var rate = 0; function ratelimit(e) { if (rate > maxLimit) { this.disabled = true;//disabling input in case they press ESC before the redirect is complete e.preventDefault; mainRoom.sendMessage({which : 13, shiftKey : false, preventDefault : function {} }) document.location.href = wgServer+"/wiki/Project:Chat/Ratelimit_triggered"; return false; }	if (this.value.length>=maxLength || this.value.split('\n').length>=6) { var val = this.value.substring(0,maxLength).split('\n'); val = val[0]+'\n'+val[1]+'\n'+val[2]+'\n'+val[3]+'\n'+val[4];//remove all lines after the 5th line. this.value = val; if (e.type == 'keypress') { e.preventDefault; return false; }	}	if (e.type == 'keypress' && e.which == 13 && !e.shiftKey && this.value != '') { rate += 1; setTimeout(function {			if (rate > 0) { rate -= 1 }		},limitTimeout); } } $('[name="message"]').keyup(ratelimit).keypress(ratelimit).keydown(ratelimit); // ******************* // END Spam protection // *******************

importScriptPage('MediaWiki:Chat.js/ChatOptions.js', 'legominifiguresonline'); $(".Rail .WikiChatList").prepend($('.Rail .WikiChatList li[data-user="' + wgUserName + '"]')); $('.Rail .WikiChatList li[data-user="' + wgUserName + '"]').addClass("you"); $(".UserStatsMenu .actions .new-actions").parent.find("ul, hr").not(".new-actions, .new-actions hr").remove; $('.Rail .WikiChatList li[data-user="' + wgUserName + '"] .UserStatsMenu .actions').html('<ul class="regular-actions new-actions"><a href="http://' + location.hostname.split(".")[0] + ".wikia.com/wiki/User_talk:" + wgUserName + '"> Talk Page </a></li> <a href="http://' + location.hostname.split(".")[0] + ".wikia.com/wiki/Special:Contributions/" + wgUserName + '"> Contributions </a></li> </ul>'); $('.Write .wikia-button[href="javascript:createGroupPM"]').length >= 1 && $('.Rail .WikiChatList li[data-user="' + wgUserName + '"] .UserStatsMenu .new-actions').append(' Start Group Chat </li>'), $('.Write .wikia-button[href="javascript:toggleAway"]').length >= 1 && $('.Rail .WikiChatList li[data-user="' + wgUserName + '"] .UserStatsMenu .new-actions').append(' Toggle Away Status </li>'), $('.Write .wikia-button[href="javascript:active.clearWindow"]').length >= 1 && $('.Rail .WikiChatList li[data-user="' + wgUserName + '"] .UserStatsMenu .new-actions').append(' Clear Chat </li>'); $("head").append('<meta name="viewport" content="width=device-width, initial-scale=1"> ');