Advertisement
pierrotdu18

Untitled

Aug 21st, 2014
233
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name        LeekWars Tchat AutoImg
  3. // @namespace   leekimg
  4. // @description Lecteur automatique d'images pour le système de tchat rapide de Leek Wars
  5. // @include     http://leekwars.com/forum
  6. // @author      Evenkore/Slexis
  7. // @version     1
  8. // @grant       none
  9. // ==/UserScript==//
  10.      
  11.     unsafeWindow.chatAddMessage = function(chat, author, authorName, msg, time, grade){
  12.             var message = unsafeWindow.protect(msg);
  13.             message = message.replace(/&amp;/g, "&amp;<null/>");
  14.             message = message.replace(/&gt;/g, "&gt;<span></span>");
  15.             message = message.replace(/&lt;/g, "&lt;<span></span>");
  16.             message = message.replace(/&quot;/g, "&quot;<span></span>");
  17.             message = unsafeWindow.smiley(message);
  18.             message = unsafeWindow.linkify(message);
  19.             message = unsafeWindow.commands(message, authorName);
  20.             message = message.replace(/<a  href="(http:\/\/.+?(?:\.gif|\.jpeg|\.jpg|\.png))">.+?<\/a>/g, '<a href="$1"><img src="$1" width="50" height="50" /></a>');
  21.             var date = new Date(time * 1000);
  22.             var minuts = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes();
  23.             var timeStr = date.getHours() + ":" + minuts;
  24.             var last = $(chat).find(".chat-message").last();
  25.             if (last.attr('author') == author && time - parseInt(last.attr('time')) < 120) last.find('.chat-message-messages').append("<div>" + message + "</div>");
  26.             else {
  27.                     var gradeClass = grade > 1 ? ["moderator", "admin"][grade - 2] : "";
  28.                     var messageData = "<div class='chat-message' author='" + author + "' time='" + time + "'>";
  29.                     messageData += "<a href='/farmer/" + author + "'><img class='chat-avatar' src='/avatar-" + author + ".png'></img></a>";
  30.                     messageData += "<a href='/farmer/" + author + "'><div class='chat-message-author " + gradeClass + "'>" + authorName + "</div></a>";
  31.                     messageData += "<div class='chat-message-time'>" + timeStr + "</div>";
  32.                     messageData += "<div class='chat-message-messages'><div>" + message + "</div></div>";
  33.                     messageData += "</div>";
  34.                     $(chat).append(messageData);
  35.             }
  36.             $(chat).scrollTop($(chat)[0].scrollHeight);
  37.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement