Chrome Extensions可以与USB设备通信吗?
Chrome应用程序可以使用Chrome.usb和Chrome.hid apis。 在编写Chrome Extensions时,这些是弃用的。 是否可以在弹出html中使用web.usb或web.hid?
在我的popup.js中,这
if ("hid" in navigator)
返回“ true”
Chrome Apps can use the Chrome.usb and Chrome.hid apis.
These are deprecated, when writing Chrome extensions.
Is it possible to use web.usb or web.hid in the popup html?
In my popup.js this
if ("hid" in navigator)
returns "True"
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,您可以从扩展名的背景页面但是请求访问设备的权限需要从选项卡(而不是弹出或背景页面)进行呼叫。
请注意,背景页面已用清单V3弃用。预计扩展将迁移到服务工作者。目前,服务人员无法访问WebUSB和WebHID。在 https://crbug.com/1303195 。
Yes, you can access WebUSB and WebHID from the extension's background page however requesting permission to access a device requires making a call from a tab (not a pop-up or the background page).
Note that the background page is deprecated with Manifest V3. Extensions are expected to migrate to Service Workers. Currently, WebUSB and WebHID are not accessible from Service Workers. Supporting this is being investigated in https://crbug.com/1303193 and https://crbug.com/1303195.