// ==UserScript== // @name 缩小标题字体 // @namespace http://tampermonkey.net/ // @version 0.1 // @description 缩小过大的字体,防止摸鱼被人看到 // @author You // @match http://*/* // @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw== // @grant none // @license MIT // @downloadURL none // ==/UserScript== (function() { 'use strict'; const func=()=>{ setTimeout(()=>{ Array.from(document.getElementsByTagName('*')).forEach(ele=>{ const fontSizeStr = getComputedStyle(ele).fontSize; const res = fontSizeStr.match(/(\d+)(\w+)/); if(!res) return; const num = res .at(1); const unit = res .at(2); const isTooBig = unit==='rem' ? Number(num) > 1:Number(num) > 20 ele.style.fontSize = '16px'; //console.log('fontSizeStr 已被替换',fontSizeStr) }) console.log('缩小字体完成'); },1000) } func(); window.addEventListener('hashchange',()=>{ console.log('hash change'); func(); }) //缩小过大的字体,防止摸鱼被人看到 })();