Mouse Throttler

Throttles your cursor to make it run at 20hz. Useful for websites that have lag induced by a high cursor polling rate. Also features auto-precision when your mouse stops moving to ensure unaltered cursor aim. Keywords: throttle mouse lag cursor lag starblast.io starblast dueling fps uncap bypass unlimiter unlock mod 60fps bugfix

  1. // ==UserScript==
  2. // @name Mouse Throttler
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.0
  5. // @description Throttles your cursor to make it run at 20hz. Useful for websites that have lag induced by a high cursor polling rate. Also features auto-precision when your mouse stops moving to ensure unaltered cursor aim. Keywords: throttle mouse lag cursor lag starblast.io starblast dueling fps uncap bypass unlimiter unlock mod 60fps bugfix
  6. // @author ✨Stardust™
  7. // @match *://*/*
  8. // @grant none
  9. // @run-at document-start
  10. // @license MIT
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. console.log('It actually worked?');
  15.  
  16. let lastTime = 0;
  17. let mouseStoppedTimeout;
  18.  
  19. //\// ////////////////////////////////// // //////////// ////////////////// // //////////// //
  20. //*// ∨∨∨∨∨∨∨∨∨∨∨∨∨∨∨∨∨∨∨∨∨∨∨∨∨∨∨∨∨∨∨ // <!<!<!<!<!<! EDIT THROTTLE RATE // <!<!<!<!<!<! //
  21. /*/*/ let throttleRateInMiliseconds = 50 // <!<!<!<!<!<! 16.66(6) = 1 FRAME // <!<!<!<!<!<! //
  22. //*// ∧∧∧∧∧∧∧∧∧∧∧∧∧∧∧∧∧∧∧∧∧∧∧∧∧∧∧∧∧∧∧ // <!<!<!<!<!<! 16.666666, not (6) // <!<!<!<!<!<! //
  23. //\// \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ // \\\\\\\\\\\\ \\\\\\\\\\\\\\\\\\ // \\\\\\\\\\\\ //
  24.  
  25. function throttle(callback, limit) {
  26. return function(event) {
  27. const now = Date.now();
  28.  
  29. if (now - lastTime >= limit) {
  30. lastTime = now;
  31. callback(event); }
  32. else {
  33. event.stopImmediatePropagation(); }
  34.  
  35. clearTimeout(mouseStoppedTimeout);
  36.  
  37. mouseStoppedTimeout = setTimeout(() => {callback(event);}, limit); }; }
  38.  
  39. document.addEventListener('mousemove', throttle((event) => { /*You can put other stuff here if you need, but you won't need to*/ }, throttleRateInMiliseconds), true); }) ();