// ==UserScript== // @name 随机写入100个不同字符到剪切板 // @namespace https://viayoo.com/6a4j69 // @version 0.3 // @description 纯粹自用脚本,MIUI剪切板写入字符超过2w+后,底栏的无法显示剪切板内容,只有不断写入,超过限定剪切板数量,才能显示新的剪切板。 // @author Via // @match *://*/* // @grant GM_setClipboard // @grant GM_registerMenuCommand // @run-at document-idle // ==/UserScript== (() => { 'use strict'; let chars = [], i = 0, bar = null; const POOL = "ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnpqrstuvwxyz23456789~!@#$%^&*_-+=<>?"; const make = () => { const a = POOL.split(''); for (let x = a.length - 1; x > 0; x--) { const j = Math.floor(Math.random() * (x + 1)); [a[x], a[j]] = [a[j], a[x]]; } return a.slice(0, 100); }; const copy = t => { if (typeof GM_setClipboard === 'function') GM_setClipboard(t); else if (navigator.clipboard?.writeText) navigator.clipboard.writeText(t); else { const e = document.createElement('textarea'); e.value = t; e.style.position = 'fixed'; e.style.opacity = '0'; document.body.appendChild(e); e.select(); document.execCommand('copy'); e.remove(); } }; const createBar = () => { bar = document.createElement('div'); bar.innerHTML = `
0 / 100
`; Object.assign(bar.style, { position: 'fixed', top: '50%', left: '50%', transform: 'translate(-50%, -50%)', minWidth: '300px', maxWidth: '88vw', padding: '24px 32px', background: 'rgba(255, 255, 255, 0.72)', // 经典 iOS 半透明白天毛玻璃 backdropFilter: 'blur(20px) saturate(180%)', // 高斯模糊 + 高饱和 WebkitBackdropFilter: 'blur(20px) saturate(180%)', borderRadius: '26px', // 大圆角,和你参考的脚本一模一样 border: '1px solid rgba(255, 255, 255, 0.4)', // 微亮边框增加质感 boxShadow: '0 12px 32px rgba(0,0,0,0.18), 0 4px 12px rgba(0,0,0,0.12)', zIndex: '2147483647', pointerEvents: 'none', textAlign: 'center', fontFamily: '-apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif', opacity: '0', transform: 'translate(-50%, -50%) scale(0.92)', transition: 'all .65s cubic-bezier(0.22,1,0.36,1)' }); document.body.appendChild(bar); requestAnimationFrame(() => { bar.style.opacity = '1'; bar.style.transform = 'translate(-50%, -50%) scale(1)'; }); }; const progress = () => { if (!bar) createBar(); bar.firstElementChild.textContent = i + ' / 100'; bar.querySelector('#p').style.width = i + '%'; if (i >= 100) { const p = bar.querySelector('#p'); p.style.background = 'linear-gradient(90deg,#34C759,#32D74B)'; p.style.boxShadow = '0 0 24px rgba(52,199,89,0.8)'; setTimeout(() => { bar.style.transform = 'translate(-50%, -50%) scale(0.92)'; bar.style.opacity = '0'; setTimeout(() => bar?.remove(), 700); }, 900); } }; const run = () => { copy(chars[i++]); progress(); }; const start = mode => { if (i > 0) return alert('请刷新页面后再操作'); chars = make(); i = 0; if (bar) bar.remove(); bar = null; progress(); if (mode === 'lightning') { while (i < 100) run(); } else { const id = setInterval(() => { if (i >= 100) clearInterval(id); else run(); }, 60); } }; GM_registerMenuCommand('光速复制 100 个字符(瞬间完成)', () => start('lightning')); GM_registerMenuCommand('快速复制 100 个字符(约6秒)', () => start()); })();