Reply-command

Adds a reply command

Versión del día 6/3/2016. Echa un vistazo a la versión más reciente.

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