使用 chrome 浏览器新建标签网址使用下面的代码: javascript:(function(){const showToast=(msg,color)=>{let t=document.createElement(‘div’);t.textContent=msg;t.style.cssText=’position:fixed; top:20px; right:20px; background:#333; color:#fff; padding:8px 16px; border-radius:4px; font-size:14px; z-index:999999; opacity:0; transition:opacity 0.3s;’;document.body.appendChild(t);setTimeout(()=>t.style.opacity=’1′,10);setTimeout(()=>{t.style.opacity=’0′;setTimeout(()=>document.body.removeChild(t),300);},2000);};const copyText=t=>{let n=document.createElement(‘input’);n.setAttribute(‘value’,t);document.body.appendChild(n);n.select();document.execCommand(‘copy’);document.body.removeChild(n);showToast(‘✅ 颜色已复制: ‘+t);console.log(‘颜色已通过传统方式复制:’,t);};if(‘EyeDropper’in window){new window.EyeDropper().open().then(async r=>{let c=r.sRGBHex;try{await navigator.clipboard.writeText(c);showToast(‘✅ 颜色已复制: ‘+c);console.log(‘颜色已复制:’,c);}catch(e){console.warn(‘Clipboard API 失败,尝试传统复制方式’);copyText(c);}}).catch(e=>console.log(‘取色取消或失败:’,e));}else{console.warn(‘浏览器不支持 EyeDropper API ,请使用 Chrome/Edge 95+’);}})();
Read More