Character-limit *OLD*

Stops and tells you when past the chat limit

  1. // ==UserScript==
  2. // @name Character-limit *OLD*
  3. // @namespace tag://kongregate
  4. // @description Stops and tells you when past the chat limit
  5. // @include http://www.kongregate.com/games/*
  6. // @version 1.5.2
  7. // @date 12.11.10
  8. // @author Ventero
  9. // require http://kong.ventero.de/updates/48979.js
  10. // ==/UserScript==
  11.  
  12. // Written by Ventero (http://www.kongregate.com/accounts/Ventero) 05/12/09
  13.  
  14. var dom = (typeof unsafeWindow === "undefined" ? window : unsafeWindow);
  15.  
  16. function init_characterLimitVent(){
  17.  
  18. var CDialogue = dom.ChatDialogue;
  19.  
  20. if(CDialogue){
  21. CDialogue.prototype = dom.CDprototype||dom.ChatDialogue.prototype;
  22.  
  23. if(!CDialogue.prototype.oldKeyPressLimit){
  24. CDialogue.prototype.oldKeyPressLimit = CDialogue.prototype.onKeyPress;
  25. CDialogue.prototype.onKeyPress = function (a) {
  26. var node = (this._input_node.wrappedJSObject || this._input_node);
  27. this.oldKeyPressLimit(a);
  28. if (node.getValue().length > 249) {
  29. z = node.getValue();
  30. var y = "";
  31. if (n=z.match(/^(\/\S+\s+\S*\s*)(.*)/)){
  32. y=n[2];
  33. if (y.length>249){
  34. node.setValue(n[1]+y.substr(0, 249))
  35. }
  36. }else{
  37. node.setValue(node.getValue().substr(0, 249))
  38. }
  39. }
  40. }
  41. }
  42. };
  43. };
  44.  
  45. function check(){
  46. dom.injectScript = dom.injectScript||(document.getElementById("injectScriptDiv")?document.getElementById("injectScriptDiv").onclick():0);
  47. if(dom.injectScript){
  48. dom.injectScript(init_characterLimitVent, 0);
  49. } else if(!dom._promptedFramework && !/Chrome/i.test(navigator.appVersion)){
  50. if(confirm("You don't have the latest version of the framework-script!\n" +
  51. "Please install it, otherwise the scripts won't work.\n" +
  52. "Clicking ok will open a new tab where you can install the script"))
  53. window.open("https://greasyfork.org/scripts/17703", "_blank");
  54. dom._promptedFramework = true;
  55. }
  56. }
  57.  
  58. setTimeout(check, 0);