chrome95版本以后新增EyeDropper api支持通过js来获取电脑屏幕任意位置的颜色值了,示例代码:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0,maximum=1.0,minimum=1.0,user-scalable=0" />
<title>BFW NEW PAGE</title>
<style>
.preview {
height: 30px;
border-radius: 15px;
width: 30px;
display: block;
float: left;
}
</style>
</head>
<body>
<div class="output">
<span class="preview"></span>
<input type="text" class="color">
<button class="getColor">点击取色</button>
</div>
<script>
if (!window.EyeDropper) {
window.pre.innerHTML = "需要Chrome 95以上才支持屏幕取色";
}
const getColor = async e => {
const eyeDropper = new EyeDropper();
try {
const { sRGBHex } = await eyeDropper.open();
document.querySelector('.preview').
style.background = sRGBHex;
document.querySelector('.color').value = sRGBHex;
} catch (e) {
document.querySelector('.color').value = '出错了';
}
};
// Click binding
document.querySelector(".getColor").
addEventListener("click", getColor);
</script>
</body>
</html> 网友回复
有没有不依赖embedding向量的RAG技术?
有没有支持实时打断语音通话并后台帮你执行任何的ai模型?
开源ai大模型文件格式GGUF、MLX、Safetensors、 ONNX 有什么区别?
出海挣钱支付收款PayPal、Wise 、PingPong、Stripe如何选择?
如何实现类似google的图片隐形水印添加和识别技术?
linux上如何运行任意windows程序?
ai能写出比黑客还厉害的零日漏洞等攻击工具攻击任意软件系统工程?
js如何获取浏览器的音频上下文指纹、Canvas指纹、WebGL渲染特征?
为啥ai开始抛弃markdown文本,重新偏好html文本了?
网站有没有办法鉴别访问请求是由ai操控chrome-devtools-mcp发出的?


