// ==UserScript== // @name 页面字号调节 // @namespace https://cxbank.icu/fontsize // @version 1.0.0 // @description 一键放大或缩小网页字号,记忆每个网站的设置。 // @author ZZ // @match *://*/* // @grant none // @run-at document-idle // ==/UserScript== (function () { 'use strict'; var KEY = 'fs_scale'; var S = { scale: 100 }; try { S.scale = Number(localStorage.getItem(KEY)) || 100; } catch (e) {} function apply() { try { document.documentElement.style.fontSize = (S.scale / 100 * 16) + 'px'; try { localStorage.setItem(KEY, String(S.scale)); } catch (e) {} var lab = document.getElementById('fs-lab'); if (lab) lab.textContent = S.scale + '%'; } catch (e) {} } function build() { if (!document.body || document.getElementById('fs-box')) return; var box = document.createElement('div'); box.id = 'fs-box'; box.style.cssText = 'position:fixed;right:14px;bottom:56px;z-index:2147483000;' + 'display:flex;gap:6px;align-items:center;padding:6px 9px;border-radius:99px;' + 'background:rgba(255,255,255,.96);border:.5px solid rgba(0,0,0,.12);' + 'box-shadow:0 6px 18px rgba(0,0,0,.16);font:12px/1 -apple-system,sans-serif;color:#1c1c1e'; box.innerHTML = '' + '' + S.scale + '%' + ''; box.querySelector('#fs-m').onclick = function () { S.scale = Math.max(70, S.scale - 10); apply(); }; box.querySelector('#fs-p').onclick = function () { S.scale = Math.min(200, S.scale + 10); apply(); }; document.body.appendChild(box); } apply(); if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', build); } else { build(); } })();