Reply-command (hotkey) *OLD*

Inserts the username of the last user who whispered you when pressing Alt-R

  1. // ==UserScript==
  2. // @name Reply-command (hotkey) *OLD*
  3. // @namespace tag://kongregate
  4. // @description Inserts the username of the last user who whispered you when pressing Alt-R
  5. // @include http://www.kongregate.com/games/*
  6. // @author Ventero
  7. // @version 1.6.2
  8. // @date 03.02.11
  9. // @license MIT license
  10. // require https://greatest.deepsurf.us/scripts/18205-reply-command-hotkey-library/code/Reply-command%20(hotkey)%20Library.js?version=114936
  11. // ==/UserScript==
  12.  
  13. // Written by Ventero (http://www.kongregate.com/accounts/Ventero) 05/02/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_replyHotkey(){
  20.  
  21. var holodeck = dom.holodeck,
  22. CDialogue = dom.ChatDialogue;
  23.  
  24. if (CDialogue && holodeck){
  25. CDialogue.prototype = dom.CDprototype||dom.ChatDialogue.prototype;
  26.  
  27. if(!CDialogue.prototype.oldKeyPressReplyHotkey){
  28. CDialogue.prototype.oldKeyPressReplyHotkey = CDialogue.prototype.onKeyPress;
  29.  
  30. CDialogue.prototype.onKeyPress = function (a) {
  31. var node = (this._input_node.wrappedJSObject || this._input_node);
  32. if (a.which == 13) {
  33. this.cnt=0;
  34. } else if (a.altKey && a.which == 114) {
  35. this.cnt+=1;
  36. l=this._holodeck._replyHotkey.length||-1;
  37. reply=this._holodeck._replyHotkey[l-this.cnt]||"";
  38. if(reply && this.cnt<=l){
  39. if(z=node.getValue()){
  40. if(z.match(/^\/[\s]*/)){
  41. z=z.replace(/^([^\s]+)\s*[^\s]*\s*(.*)/, '/w '+reply+' $2')
  42. }else{
  43. z="/w "+reply+" "+z
  44. };
  45. this.setInput(z)
  46. }else{
  47. this._holodeck.insertPrivateMessagePrefixFor(reply);
  48. }
  49. }else if(this.cnt>l){
  50. z=node.getValue();
  51. if (z=="/w "+this._holodeck._replyHotkey[0]+" "){
  52. this.setInput("/w ");
  53. this.cnt=0;
  54. }else if(z=="" && l>0){
  55. this.cnt-=1;
  56. this.setInput("/w "+this._holodeck._replyHotkey[l-this.cnt]+" ");
  57. }else{
  58. r=z.match(/^\/[^\s]+\s+[^\s]+\s+(.*)/);
  59. r&&(z=r[1]);
  60. this.setInput(z);
  61. this.cnt=0;
  62. }
  63. }
  64. }
  65. this.oldKeyPressReplyHotkey(a);
  66. }
  67.  
  68. CDialogue.prototype.cnt=0;
  69.  
  70. CDialogue.prototype.whisperArray = function(a,x){var i=a.indexOf(x);if(-1!==i)a.splice(i, 1);return a.concat(x);};
  71.  
  72. if(CDialogue.prototype.reply){
  73. CDialogue.prototype.oldreplyHotkey = CDialogue.prototype.reply
  74. } else {
  75. CDialogue.prototype.oldreplyHotkey = function(a){};
  76. }
  77.  
  78. CDialogue.prototype.reply = function(a){
  79. this._holodeck._replyHotkey=this.whisperArray(this._holodeck._replyHotkey, a);
  80. this.oldreplyHotkey(a);
  81. }
  82.  
  83. if(!CDialogue.prototype.showReceivedPM){
  84. CDialogue.prototype.showReceivedPM = CDialogue.prototype.receivedPrivateMessage;
  85. CDialogue.prototype.receivedPrivateMessage = function(a){
  86. if (a.data.success){
  87. this.reply(a.data.from)
  88. }
  89. this.showReceivedPM(a);
  90. }
  91. }
  92.  
  93.  
  94. holodeck._replyHotkey= new Array();
  95. }
  96. }
  97. };
  98.  
  99. function check(){
  100. dom.injectScript = dom.injectScript||(document.getElementById("injectScriptDiv")?document.getElementById("injectScriptDiv").onclick():0);
  101. if(dom.injectScript){
  102. dom.injectScript(init_replyHotkey, 0);
  103. } else if(!dom._promptedFramework && !/Chrome/i.test(navigator.appVersion)){
  104. if(confirm("You don't have the latest version of the framework-script!\n" +
  105. "Please install it, otherwise the scripts won't work.\n" +
  106. "Clicking ok will open a new tab where you can install the script"))
  107. window.open("http://userscripts.org/scripts/show/54245", "_blank");
  108. dom._promptedFramework = true;
  109. }
  110. }
  111.  
  112. setTimeout(check, 0);