Chrome Extensions可以与USB设备通信吗?

发布于 2025-01-27 15:05:48 字数 197 浏览 3 评论 0原文

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

酷炫老祖宗 2025-02-03 15:05:48

是的,您可以从扩展名的背景页面但是请求访问设备的权限需要从选项卡(而不是弹出或背景页面)进行呼叫。

请注意,背景页面已用清单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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文