V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
meetthebest
V2EX  ›  分享发现

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

  •  
  •   meetthebest · 4 小时 25 分钟前 · 514 次点击
    使用 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+');}})();
    8 条回复    2026-02-26 15:05:15 +08:00
    cryptovae
        1
    cryptovae  
       4 小时 21 分钟前
    chrome `javascript:` 不让粘贴,有点意思
    grassblock007
        2
    grassblock007  
       4 小时 19 分钟前 via Android
    小书签,启动!
    meetthebest
        3
    meetthebest  
    OP
       4 小时 16 分钟前
    @cryptovae 可以吧,都已经在用了。(可能需要一起浏览器权限🤔)
    meetthebest
        4
    meetthebest  
    OP
       4 小时 16 分钟前
    (可能需要一些浏览器权限🤔)
    xiaowoli
        5
    xiaowoli  
       4 小时 14 分钟前
    meetthebest
        6
    meetthebest  
    OP
       4 小时 12 分钟前
    meetthebest
        7
    meetthebest  
    OP
       4 小时 10 分钟前
    我的 chrome 版本是 145.0.7632.75 (正式版本) (arm64);
    使用这个 API new window.EyeDropper ( https://developer.mozilla.org/zh-CN/docs/Web/API/EyeDropper ) chrome 需>95
    nullfeng
        8
    nullfeng  
       3 小时 23 分钟前
    很不错~nice
    关于   ·   帮助文档   ·   自助推广系统   ·   博客   ·   API   ·   FAQ   ·   Solana   ·   3722 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 10:29 · PVG 18:29 · LAX 02:29 · JFK 05:29
    ♥ Do have faith in what you're doing.