推荐一个优雅的取色器方案
使用 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©;showToast(‘✅ 颜色已复制: ‘+c);console.log(‘颜色已复制:’,c);}catch(e){console.warn(‘Clipboard API 失败,尝试传统复制方式’);copyText©;}}).catch(e=>console.log(‘取色取消或失败:’,e));}else{console.warn(‘浏览器不支持 EyeDropper API ,请使用 Chrome/Edge 95+’);}})();
小书签,启动!
@cryptovae 可以吧,都已经在用了。(可能需要一起浏览器权限🤔)
(可能需要一些浏览器权限🤔)
我的 chrome 版本是 145.0.7632.75 (正式版本) (arm64); 使用这个 API new window.EyeDropper ( https://developer.mozilla.org/zh-CN/docs/Web/API/EyeDropper ) chrome 需>95
chrome
javascript:不让粘贴,有点意思