Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name LeekWars Tchat AutoImg
- // @namespace leekimg
- // @description Lecteur automatique d'images pour le système de tchat rapide de Leek Wars
- // @include http://leekwars.com/forum
- // @author Evenkore/Slexis
- // @version 1
- // @grant none
- // ==/UserScript==//
- unsafeWindow.chatAddMessage = function(chat, author, authorName, msg, time, grade){
- var message = unsafeWindow.protect(msg);
- message = message.replace(/&/g, "&<null/>");
- message = message.replace(/>/g, "><span></span>");
- message = message.replace(/</g, "<<span></span>");
- message = message.replace(/"/g, ""<span></span>");
- message = unsafeWindow.smiley(message);
- message = unsafeWindow.linkify(message);
- message = unsafeWindow.commands(message, authorName);
- message = message.replace(/<a href="(http:\/\/.+?(?:\.gif|\.jpeg|\.jpg|\.png))">.+?<\/a>/g, '<a href="$1"><img src="$1" width="50" height="50" /></a>');
- var date = new Date(time * 1000);
- var minuts = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes();
- var timeStr = date.getHours() + ":" + minuts;
- var last = $(chat).find(".chat-message").last();
- if (last.attr('author') == author && time - parseInt(last.attr('time')) < 120) last.find('.chat-message-messages').append("<div>" + message + "</div>");
- else {
- var gradeClass = grade > 1 ? ["moderator", "admin"][grade - 2] : "";
- var messageData = "<div class='chat-message' author='" + author + "' time='" + time + "'>";
- messageData += "<a href='/farmer/" + author + "'><img class='chat-avatar' src='/avatar-" + author + ".png'></img></a>";
- messageData += "<a href='/farmer/" + author + "'><div class='chat-message-author " + gradeClass + "'>" + authorName + "</div></a>";
- messageData += "<div class='chat-message-time'>" + timeStr + "</div>";
- messageData += "<div class='chat-message-messages'><div>" + message + "</div></div>";
- messageData += "</div>";
- $(chat).append(messageData);
- }
- $(chat).scrollTop($(chat)[0].scrollHeight);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement