如何通过浏览器控制台加速第三方网站的setTimeout倒计时器?
Shorten 1-Hour Timer to 20/30 Minutes via Browser Console
Alright, let's tackle this problem directly. Since you can't edit the site's source code, we'll override the existing timer logic using your browser's JavaScript console. Here's exactly how to do it:
Step 1: Understand the Original Timer Logic
The site uses two key components for the timer:
- A
countdownplugin that displays the minutes/seconds timer (set to 3600 seconds = 1 hour) - A
setTimeoutthat triggersRefreshPageAfterFreePlayTimerEnds()after 1 hour to reset the button
We need to replace both with our desired 20 or 30-minute duration.
Step 2: Run This Code in Your Browser Console
First, open your browser's developer tools (press F12 or Ctrl+Shift+I), switch to the Console tab, then paste the code below. Adjust the duration by changing the newWaitSeconds value:
// Save the original refresh function so we can still use it later const originalRefresh = window.RefreshPageAfterFreePlayTimerEnds; // Clear ALL existing timeouts (the original 1-hour timeout has no variable reference, so this is the safest way) let timerId = setTimeout(() => {}, 0); while (timerId--) { clearTimeout(timerId); } // Destroy the original countdown timer instance $('#time_remaining').countdown('destroy'); // Set your desired wait time in seconds: 20 mins = 1200, 30 mins = 1800 const newWaitSeconds = 1200; // Initialize a new countdown with your custom duration $('#time_remaining').countdown({ until: +newWaitSeconds, format: 'MS', // Keep the minutes/seconds display format onExpiry: function() { // Trigger the original refresh function when our timer ends originalRefresh(); } });
How It Works
- Clearing Timeouts: The original 1-hour timeout isn't stored in a variable, so we loop through all possible timer IDs to clear it—this ensures it won't fire later and interfere with our custom timer.
- Replacing the Countdown: We destroy the old countdown instance and create a new one with your chosen duration (1200 seconds for 20 mins, 1800 for 30 mins).
- Preserving Functionality: We save and reuse the original
RefreshPageAfterFreePlayTimerEnds()function so the page behaves exactly as it should when the timer finishes.
Notes
- This only applies to your current browser session—if you refresh the page, you'll need to run the code again after clicking "Roll".
- Make sure to run this code right after the original timer starts (after clicking "Roll").
内容的提问来源于stack exchange,提问作者Ram Lal
相关产品推荐
相关产品推荐

