Greasy Fork 支持简体中文。

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