今天刷课的时候了解到了油猴的一些内容,并尝试写了一些一个很简易的脚本。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<span id="time"></span>
<script>
window.onload=()=>{
let now = new Date();
let hour,minute,second;
hour = now.getHours();
minute = now.getMinutes();
second = now.getSeconds();
let work = ()=>{
document.querySelector('#time').innerText = hour + ":" + minute + ":" + second;
second ++;
if(second >= 60)
{
minute += second/60,second %= 60;
}
if(minute >= 60) hour+=minute/60,minute %= 60;
if(hour >= 24) hour = hour % 24;
};
setInterval(work,1000);
}
</script>
</body>
</html>
// ==UserScript==
// @name HookTime
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match http://127.0.0.1:5500/time.html
// @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant none
// @run-at document-start
// ==/UserScript==
(function() {
'use strict';
// Your code here...
let hookSetInterval = window.setInterval;
window.setInterval = function(a,b){
return hookSetInterval(a,b/10);
}
})();
效果是 时间加速了10倍, 不考虑其他的话 最简单的想的话,刷课的话,相当于开了10倍速。