Timer Accelerator1000X

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

当前为 2025-03-20 提交的版本,查看 最新版本

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