IP.Chat Extended History + Concise Format

Extend IP.Chat history and make messages concise (optional).

  1. // ==UserScript==
  2. // @name IP.Chat Extended History + Concise Format
  3. // @namespace Makaze
  4. // @include *
  5. // @version 1.2.4
  6. // @description Extend IP.Chat history and make messages concise (optional).
  7. // ==/UserScript==
  8.  
  9. var extend,
  10. opts = (localStorage.getItem('MakazeScriptOptions')) ? JSON.parse(localStorage.getItem('MakazeScriptOptions')) : {},
  11. applyConcise = (opts.hasOwnProperty('ipc_apply_concise')) ? opts.ipc_apply_concise : false,
  12. extendHistory = (opts.hasOwnProperty('ipc_extend_history')) ? opts.ipc_extend_history : true,
  13. extension = (opts.hasOwnProperty('ipc_history_extension')) ? opts.ipc_history_extension : 10000,
  14. changeInactiveKick = (opts.hasOwnProperty('ipc_change_inactive_kick')) ? opts.ipc_change_inactive_kick : true,
  15. inactiveKick = (opts.hasOwnProperty('ipc_inactive_kick')) ? opts.ipc_inactive_kick : 0;
  16.  
  17. function extendHistoryFunc() {
  18. ipb.chat.maxMessages = extension;
  19. }
  20.  
  21. function changeInactiveKickFunc() {
  22. ipb.chat.inactiveKick = inactiveKick;
  23. }
  24.  
  25. function applyConciseFunc() {
  26. ipb.chat.templates['msg-1'] = new Template( "<li class='post chat-message #{ownclass}'><div style='margin-left: 0px; padding: 0px 5px;'><label style='margin: 0px; display: inline;'>#{username}</label>: <div style='display: inline; margin-left: 0px;'>#{message}</div></div></li>" );
  27. ipb.chat.templates['msg-1-compound'] = new Template( "<li class='post chat-message #{ownclass}'><div style='margin-left: 0px; padding: 0px 5px;'><label style='margin: 0px; display: inline;'>#{username}</label>: <div style='display: inline; margin-left: 0px;'>#{message}</div></div></li>" );
  28. ipb.chat.templates['msg-2'] = new Template( "<li class='post chat-notice'><div style='margin-left: 0px; padding: 0px 5px;'><label style='margin: 0px; display: inline;'>#{username}</label>#{action}</div></li>" );
  29. ipb.chat.templates['msg-3'] = new Template( "<li class='post chat-me'><div style='margin-left: 0px; padding: 0px 5px;'>**<label style='margin: 0px; display: inline;'>#{username}</label> #{message}**</div></li>" );
  30. ipb.chat.templates['msg-4'] = new Template( "<li class='post chat-system'>SYSTEM MESSAGE: #{message}</li>" );
  31. ipb.chat.templates['msg-5'] = new Template( "<li class='post chat-moderator'><div style='margin-left: 0px; padding: 0px 5px;'><label class='fluid' style='margin: 0px; display: inline;'>#{username}</label> kicked #{extra}</div></li>" );
  32. ipb.chat.templates['msg-K'] = new Template( "<li class='post chat-moderator'><div style='margin-left: 0px; padding: 0px 5px;'>You have been kicked from the chat room</div></li>" );
  33. }
  34.  
  35. if (document.body.id === 'ipboard_body' && document.getElementById('storage_chatroom') != null) {
  36. extend = document.createElement('script');
  37. extend.setAttribute('type', 'text/javascript');
  38. extend.id = 'IPChatExtension';
  39. if (extendHistory) {
  40. extend.innerHTML += extendHistoryFunc.toString() + 'extendHistoryFunc();';
  41. }
  42. if (changeInactiveKick) {
  43. extend.innerHTML += changeInactiveKickFunc.toString() + 'changeInactiveKickFunc();';
  44. }
  45. if (applyConcise) {
  46. extend.innerHTML += applyConciseFunc.toString() + 'applyConciseFunc();';
  47. }
  48.  
  49. document.body.appendChild(extend);
  50. }