Miracle Scripts

Let your cell spin, jump, shake, flip and wacky! Copy & paste custom emojis to the chatbox!

当前为 2019-10-16 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Miracle Scripts
  3. // @namespace Miracle Scripts
  4. // @version 1.0
  5. // @description Let your cell spin, jump, shake, flip and wacky! Copy & paste custom emojis to the chatbox!
  6. // @homepage http://agarioforums.net/member.php?action=profile&uid=21263
  7. // @author You
  8. // @license MIT
  9. // @icon https://abload.de/img/mh3k8o.png
  10. // @match http://agma.io/
  11. // @grant none
  12. // ==/UserScript==
  13.  
  14. (function() {
  15. 'use strict';
  16.  
  17. // Mouse button to use to start. Null = do not listen to mouse click.
  18. // 0 = left, 1 = middle, 2 = right
  19. var startMouseButton = null
  20.  
  21. // Key to use to start. Null = do not key press..
  22. // Use this tool to find out key codes - just press a button: https://unixpapa.com/js/testkey.html
  23. // 17 = CTRL
  24. var startKeyCode = 17;
  25.  
  26. // True = Combine wacky with others animations,
  27. // False = Only other aninmations
  28. var combine = true;
  29.  
  30. /**
  31. * Returns a random number between min (inclusive) and max (exclusive)
  32. * Source: MDN
  33. */
  34. var getRandomArbitrary = function(min, max) {
  35. return Math.random() * (max - min) + min;
  36. }
  37.  
  38. var chatAnimate = function()
  39. {
  40. // The available commands
  41. var items = ['spin', 'flip', 'shake', 'jump'];
  42.  
  43. // Choose randomly an item of the items array
  44. // Source: https://stackoverflow.com/questions/5915096/get-random-item-from-javascript-array
  45. var item = items[Math.floor(Math.random()*items.length)];
  46.  
  47. if (combine) {
  48. item = 'wacky' + item;
  49. }
  50.  
  51. // Add text into the chatbox and focus it
  52. $('#chtbox').val('/' + item).focus();
  53.  
  54. // Stop the event so that the pressed key won't be written into the chatbox!
  55. event.preventDefault();
  56. }
  57.  
  58. window.addEventListener('mousedown', function(event)
  59. {
  60. if (event.button == startMouseButton) {
  61. chatAnimate();
  62. }
  63. });
  64. window.addEventListener('keydown', function(event)
  65. {
  66. if (event.keyCode == startKeyCode && ! event.shiftKey) {
  67. chatAnimate();
  68. }
  69. });
  70. })();
  71.  
  72.  
  73. (function() {
  74. 'use strict';
  75.  
  76. // Key to use to start. Null = do not key press..
  77. // Use this tool to find out key codes - just press a button: https://unixpapa.com/js/testkey.html
  78. // 36 = POS1
  79. var startKeyCode = 36;
  80.  
  81. window.addEventListener('keydown', function(event)
  82. {
  83. if (event.keyCode == startKeyCode && ! event.shiftKey) {
  84. var text = prompt('Please paste your text or emjoi here');
  85.  
  86. // focus() only works when there is a delay after the prompt has been closed
  87. setTimeout(function(){
  88. // Add text into the chatbox and focus it
  89. $('#chtbox').val(text).focus();
  90. }, 200);
  91. }
  92. });
  93. })();
  94.  
  95. console.log('🌸 Miracle Scripts successfully loaded!');

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址