Reply-command *OLD*

Adds a reply command

  1. // ==UserScript==
  2. // @name Reply-command *OLD*
  3. // @namespace tag://kongregate
  4. // @description Adds a reply command
  5. // @include http://www.kongregate.com/games/*
  6. // @author Ventero
  7. // @version 1.8.3
  8. // @date 13.03.2011
  9. // @license MIT license
  10. // @require https://greatest.deepsurf.us/scripts/18199-ventero-s-autoupdater-framework/code/Ventero's%20AutoUpdater%20Framework.js?version=114918
  11. // ==/UserScript==
  12.  
  13. // Written by Ventero (http://www.kongregate.com/accounts/Ventero) 05/01/09
  14. // Copyright (c) 2009-2012 Ventero, licensed under MIT/X11 license
  15. // http://www.opensource.org/licenses/mit-license.php
  16.  
  17. var dom = (typeof unsafeWindow === "undefined" ? window : unsafeWindow);
  18.  
  19. function init_reply(){
  20.  
  21. var CDialogue = dom.ChatDialogue;
  22.  
  23. if (CDialogue){
  24.  
  25. CDialogue.prototype = dom.CDprototype||dom.ChatDialogue.prototype;
  26. if(!CDialogue.prototype.oldKeyPressReply){
  27.  
  28. CDialogue.prototype.oldKeyPressReply = CDialogue.prototype.onKeyPress;
  29.  
  30. if(CDialogue.prototype.reply){
  31. CDialogue.prototype.oldreply = CDialogue.prototype.reply
  32. } else {
  33. CDialogue.prototype.oldreply = function(a){};
  34. }
  35. CDialogue.prototype.reply = function(a){
  36. this._holodeck._reply = a;
  37. this.oldreply(a);
  38. }
  39.  
  40. if(!CDialogue.prototype.showReceivedPM){
  41. CDialogue.prototype.showReceivedPM = CDialogue.prototype.receivedPrivateMessage;
  42. CDialogue.prototype.receivedPrivateMessage = function(a){
  43. if (a.data.success){
  44. this.reply(a.data.from)
  45. }
  46. this.showReceivedPM(a);
  47. }
  48. }
  49.  
  50. CDialogue.prototype.onKeyPress = function (a) {
  51. var z, node = (this._input_node.wrappedJSObject || this._input_node);
  52. if(a.which == 32 &&
  53. ((a.currentTarget.selectionStart == 2 && (z = node.getValue().match(/^\/r(.*)/i))) ||
  54. (z = node.getValue().match(/^\/r\b(.*)/i)))){
  55. var x=z[1]||"";
  56. if (this._holodeck._reply) {
  57. this.setInput("/w "+this._holodeck._reply+" "+x);
  58. } else {
  59. this.setInput("/w ");
  60. }
  61. if(a.stop) a.stop();
  62. if(a.preventDefault) a.preventDefault();
  63. };
  64.  
  65. this.oldKeyPressReply(a);
  66. }
  67. }
  68. }
  69. };
  70.  
  71. function check(){
  72. dom.injectScript = dom.injectScript||(document.getElementById("injectScriptDiv")?document.getElementById("injectScriptDiv").onclick():0);
  73. if(dom.injectScript){
  74. dom.injectScript(init_reply, 0);
  75. } else if(!dom._promptedFramework && !/Chrome/i.test(navigator.appVersion)){
  76. if(confirm("You don't have the latest version of the framework-script!\n" +
  77. "Please install it, otherwise the scripts won't work.\n" +
  78. "Clicking ok will open a new tab where you can install the script"))
  79. window.open("http://userscripts.org/scripts/show/54245", "_blank");
  80. dom._promptedFramework = true;
  81. }
  82. }
  83.  
  84. setTimeout(check, 0);