一个好用的自律刷题插件
不是我找的,是 Gemini 生成的
具体原理可以看注释
效果就是隐藏题解入口 10 分钟,然后提醒你可以看题解了再恢复入口(当然避免不了 F12 党与打链接的)
代码:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
|
(function() { 'use strict'; const WAIT_TIME = 10 * 60 * 1000; const probId = window.location.pathname.split('/').pop(); const startTimeKey = `study_timer_${probId}`;
let startTime = localStorage.getItem(startTimeKey); if (!startTime) { startTime = Date.now(); localStorage.setItem(startTimeKey, startTime); }
const checkTimer = setInterval(() => { const elapsed = Date.now() - startTime; const solutionBtn = document.querySelector('a[href*="solution"]');
if (solutionBtn) { if (elapsed < WAIT_TIME) { solutionBtn.style.display = 'none'; } else { solutionBtn.style.display = 'inline-block'; alert("10分钟到了,如果还没思路就看看题解吧!"); clearInterval(checkTimer); } } }, 1000); })();
|
时间可以自己改,这是油猴插件,有油猴的可以添加新脚本然后把这个拷贝进去再保存就可以了。没有油猴得先下载油猴。自律插件把。