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