求助:如何修改第三方网站的maxTime变量?Chrome工具操作无效
Hey there! I’ve dealt with exactly this kind of issue when trying to tweak third-party site variables locked away in closed scopes—super frustrating when you can see the variable but can’t modify it directly. Let’s fix this so your son gets the extra time he needs.
Why Your Chrome DevTools Changes Didn’t Stick
That maxTime variable is probably wrapped in a closure (a private function scope), which means the global console can’t access or modify it permanently. Any changes you make in the console only last until the next question loads, or get overwritten by the site’s original code.
Solution 1: Use a User Script (Permanent Fix)
The easiest way to make this change stick every time you visit the site is with a user script manager like Tampermonkey. Here’s how:
- Install the Tampermonkey extension for Chrome (it’s free and safe from the Chrome Web Store).
- Click the Tampermonkey icon in your browser toolbar and select Create a new script.
- Replace the default code with this custom script:
// ==UserScript== // @name Multiplication Timer Extender // @namespace http://tampermonkey.net/ // @version 0.1 // @description Boost multiplication question timer to 20 seconds // @author Your Name // @match https://www.timestables.com/speed-test/ // @grant none // ==/UserScript== (function() { 'use strict'; // Override setTimeout to replace 10-second delays with 20-second ones const originalSetTimeout = window.setTimeout; window.setTimeout = function(callback, delay) { // Check if the delay matches the 10-second timer (10000ms) if (delay === 10000) { return originalSetTimeout(callback, 20000); // Swap to 20000ms = 20s } // Leave all other timeouts unchanged return originalSetTimeout(callback, delay); }; })();
- Save the script (Ctrl+S) and refresh the multiplication test page. Now every question will have a 20-second timer!
Solution 2: Quick DevTools Hack (One-Time Use)
If you don’t want to install an extension, you can use this method for a single session:
- Open Chrome DevTools with F12, go to the Sources tab.
- Press Ctrl+F and search for
maxTimeto find where it’s defined. - Click the line number next to the
maxTime = 10000(or similar) line to set a breakpoint. - Refresh the page or start a new test—when the breakpoint triggers, the code will pause.
- Go to the Console tab, type
maxTime = 20000, and press Enter. - Press F8 to resume execution. The current test will use the 20-second timer.
Note: You’ll need to repeat this every time you reload the page.
Both methods work because they either intercept the timer’s delay (user script) or modify the variable directly in its own scope (breakpoint hack).
内容的提问来源于stack exchange,提问作者Duke Dougal

