Timer Accelerator1000X

Accelerate JavaScript timers with safety checks. Edit @match entries for your required websites. Else, the script runs globally.

目前为 2025-03-26 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name Timer Accelerator1000X
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.1.3
  5. // @license GNU AGPLv3
  6. // @description Accelerate JavaScript timers with safety checks. Edit @match entries for your required websites. Else, the script runs globally.
  7. // @author Ex_Dr.Perimentz
  8. // @icon https://greasyfork.s3.us-east-2.amazonaws.com/n2gw8pb22uojb56dqox9ja5gg90f
  9. // @match *://online-stopwatch.com/*
  10. // @match *://downloadsite.com/*
  11. // @match *://otherdownloadsite.com/files/*
  12. // @match *://keedabankingnews.com/*
  13. // @match *://healthvainsure.site/*
  14. // @grant none
  15. // @run-at document-start
  16. // @compatible chrome
  17. // @compatible firefox
  18. // @compatible opera
  19. // @compatible edge
  20. // @compatible brave
  21.  
  22. // Copyright (C) 2025 Ex_Dr.Perimentz
  23. //
  24. // This program is free software: you can redistribute it and/or modify
  25. // it under the terms of the GNU Affero General Public License as published by
  26. // the Free Software Foundation, either version 3 of the License, or
  27. // (at your option) any later version.
  28. //
  29. // This program is distributed in the hope that it will be useful,
  30. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  31. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  32. // GNU Affero General Public License for more details.
  33. //
  34. // You should have received a copy of the GNU Affero General Public License
  35. // along with this program. If not, see <https://www.gnu.org/licenses/>.
  36.  
  37.  
  38. // ==/UserScript==
  39.  
  40. (function() {
  41. 'use strict';
  42.  
  43. // Define the acceleration factor (e.g., 1000x speedup means 1000ms becomes 1ms)
  44. const accelerationFactor = 1000;
  45.  
  46. // Define a minimum delay to avoid extremely short intervals that may be clamped by the browser
  47. const minimumDelay = 4; // milliseconds
  48.  
  49. // Store original timer functions to call later
  50. const originalSetTimeout = window.setTimeout;
  51. const originalSetInterval = window.setInterval;
  52.  
  53. // Override the global setTimeout function
  54. window.setTimeout = function(callback, delay, ...args) {
  55. // Ensure the delay is a number. If not, default to 0.
  56. delay = Number(delay) || 0;
  57.  
  58. // If the delay is positive, accelerate it by dividing by the acceleration factor,
  59. // while ensuring it doesn't drop below the minimumDelay.
  60. if (delay > 0) {
  61. delay = Math.max(minimumDelay, delay / accelerationFactor);
  62. }
  63.  
  64. // Call the original setTimeout with the modified delay
  65. return originalSetTimeout(callback, delay, ...args);
  66. };
  67.  
  68. // Override the global setInterval function similarly
  69. window.setInterval = function(callback, delay, ...args) {
  70. // Coerce delay to a number, defaulting to 0 if necessary.
  71. delay = Number(delay) || 0;
  72.  
  73. // Accelerate the delay if it's a positive number, while ensuring a minimum delay
  74. if (delay > 0) {
  75. delay = Math.max(minimumDelay, delay / accelerationFactor);
  76. }
  77.  
  78. // Call the original setInterval with the modified delay
  79. return originalSetInterval(callback, delay, ...args);
  80. };
  81.  
  82. // Log a message in the console to indicate that the timers have been accelerated
  83. console.log(`Timers accelerated by ${accelerationFactor}x.`);
  84. })();