推荐一个优雅的取色器方案

2 月 26 日
 meetthebest
使用 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+');}})();
1042 次点击
所在节点    分享发现
9 条回复
cryptovae
2 月 26 日
chrome `javascript:` 不让粘贴,有点意思
grassblock007
2 月 26 日
小书签,启动!
meetthebest
2 月 26 日
@cryptovae 可以吧,都已经在用了。(可能需要一起浏览器权限🤔)
meetthebest
2 月 26 日
(可能需要一些浏览器权限🤔)
xiaowoli
2 月 26 日
meetthebest
2 月 26 日
meetthebest
2 月 26 日
我的 chrome 版本是 145.0.7632.75 (正式版本) (arm64);
使用这个 API new window.EyeDropper ( https://developer.mozilla.org/zh-CN/docs/Web/API/EyeDropper ) chrome 需>95
nullfeng
2 月 26 日
很不错~nice
lxhcool
2 月 27 日
可以,我直接让 ai 给我写成一个扩展了

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://study.congcong.us/t/1194229

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX