// ==UserScript== // @author Zaso // @name Chat Message Length // @category Tweaks // @version 0.1.3.20200216.174028 // @description Counts the chat message characters. // @id chat-message-length@Zaso // @namespace https://github.com/IITC-CE/ingress-intel-total-conversion // @downloadURL https://raw.githubusercontent.com/IITC-CE/Community-plugins/master/dist/Zaso/chat-message-length.user.js // @updateURL https://raw.githubusercontent.com/IITC-CE/Community-plugins/master/dist/Zaso/chat-message-length.meta.js // @match https://intel.ingress.com/* // @grant none // ==/UserScript== function wrapper(plugin_info) { // ensure plugin framework is there, even if iitc is not yet loaded if(typeof window.plugin !== 'function') window.plugin = function() {}; //PLUGIN AUTHORS: writing a plugin outside of the IITC build environment? if so, delete these lines!! //(leaving them in place might break the 'About IITC' page or break update checks) plugin_info.buildName = 'ZasoItems'; plugin_info.dateTimeVersion = '2020-02-16-174028'; plugin_info.pluginId = 'chat-message-length'; //END PLUGIN AUTHORS NOTE // PLUGIN START //////////////////////////////////////////////////////// // History // 0.1.3 Headers changed. Ready for IITC-CE // 0.1.2 Original sript // use own namespace for plugin window.plugin.chatMsgLen = function(){}; window.plugin.chatMsgLen.maxChar = 256; window.plugin.chatMsgLen.chatLen = 0; window.plugin.chatMsgLen.getChatLen = function(){ return window.plugin.chatMsgLen.chatLen; } window.plugin.chatMsgLen.saveChatLen = function(){ window.plugin.chatMsgLen.chatLen = $('#chattext').val().length; } window.plugin.chatMsgLen.checkLimit = function(){ var l = window.plugin.chatMsgLen.getChatLen(); var m = window.plugin.chatMsgLen.maxChar; if(l > m){ $('#chattext-count').addClass('red'); return 0; }else{ $('#chattext-count').removeClass('red'); return 1; } } window.plugin.chatMsgLen.updateCount = function(){ window.plugin.chatMsgLen.saveChatLen(); var l = window.plugin.chatMsgLen.getChatLen(); var m = window.plugin.chatMsgLen.maxChar; $('#chattext-count').text(m-l); window.plugin.chatMsgLen.checkLimit(); } window.plugin.chatMsgLen.setupCSS = function(){ $("