Greasy Fork is available in English.

TagPro Rolling Chat

When typing out a message, you'll be able to use the arrow keys for movement.

  1. // ==UserScript==
  2. // @name TagPro Rolling Chat
  3. // @description When typing out a message, you'll be able to use the arrow keys for movement.
  4. // @author Ko
  5. // @version 3.2
  6. // @match *://*.koalabeast.com/*
  7. // @match *://*.jukejuice.com/*
  8. // @match *://*.newcompte.fr/*
  9. // @supportURL https://www.reddit.com/message/compose/?to=Wilcooo
  10. // @website https://redd.it/no-post-yet
  11. // @require https://greasyfork.org/scripts/371240/code/TagPro%20Userscript%20Library.js
  12. // @license MIT
  13. // @namespace https://greasyfork.org/users/152992
  14. // ==/UserScript==
  15.  
  16.  
  17.  
  18. // These lines announce that this script is running (handy for other scripts, possibly):
  19. // It doesn't influence the features of this script in any way.
  20. var short_name = 'rollingchat'; // An alphabetic (no spaces/numbers) distinctive name for the script.
  21. var version = GM_info.script.version; // The version number is automatically fetched from the metadata.
  22. tagpro.ready(function(){ if (!tagpro.scripts) tagpro.scripts = {}; tagpro.scripts[short_name]={version:version};});
  23. console.log('START: ' + GM_info.script.name + ' (v' + version + ' by ' + GM_info.script.author + ')');
  24.  
  25. if (tpul.playerLocation != 'game') return;
  26.  
  27. (function enableRollingChat(){
  28.  
  29. // It is perfectly fine to add this function (unchanged) to your own script.
  30. // Multiple instances of "rollingchat" can run simultaniously without problems.
  31.  
  32. // intercept all key presses and releases:
  33. document.addEventListener('keydown', keyUpOrDown);
  34. document.addEventListener('keyup', keyUpOrDown);
  35.  
  36. function keyUpOrDown( event ) {
  37.  
  38. // The key that is pressed/released (undefined when it is any other key)
  39. var arrow = ['left','up','right','down'][[37,38,39,40].indexOf(event.keyCode)]
  40.  
  41. // Only if the controls are disabled (usually while composing a message)
  42. // AND the key is indeed an arrow (not undefined)
  43. if (tagpro.disableControls && arrow) {
  44.  
  45. // Whether you are releasing instead of pressing the key:
  46. var releasing = event.type == 'keyup';
  47.  
  48. // Prevent the 'default' thing to happen, which is the cursor moving through the message you are typing
  49. event.preventDefault();
  50.  
  51. // Return if already pressed/released
  52. if (tagpro.players[tagpro.playerId].pressing[arrow] != releasing) return;
  53.  
  54. // Send the key press/release to the server!
  55. tagpro.sendKeyPress(arrow, releasing);
  56.  
  57. // Not necesarry, but useful for other scripts to 'hook onto'
  58. if (!releasing && tagpro.events.keyDown) tagpro.events.keyDown.forEach(f => f.keyDown(arrow));
  59. if (releasing && tagpro.events.keyUp) tagpro.events.keyUp.forEach(f => f.keyUp(arrow));
  60. tagpro.ping.avg&&setTimeout(()=>(tagpro.players[tagpro.playerId][arrow]=!releasing),tagpro.ping.avg/2);
  61. }
  62. }
  63. })();