Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

340
Views
Chrome, allow autoconnect for HID device

So I'm trying to read out a USB-scale thats connected to my pc. I use chrome's experimental HID api.

I use Tampermonekey as userscript injector to extend a website's functionality.

The script I inject looks like this:

navigator.hid.requestDevice({ filters: [{ vendorId: 0x0922, productId: 0x8003}] }).then((devices) => {   
    if (devices.length == 0) return;
    devices[0].open().then(() => {
        if(disconnected) {
            disconnected = false
        }
        console.log("Opened device: " + devices[0].productName);
        devices[0].addEventListener("inputreport", handleInputReport);
        devices[0].sendReport(outputReportId, outputReport).then(() => {
            console.log("Sent output report " + outputReportId);
        });
    });
});

When I run it just like this(inline) I get the message in chrome:

DOMException: Failed to execute 'requestDevice' on 'HID': Must be handling a user gesture to show a permission request.

Basically, the code needs to be inside an event listener and the listener needs to be triggered by user input to run.

Al fine and dandy, except that this has to be initialized hundreds of times a day. I tried running this code in edge and here it just works without user input.

Is there a way I can disable this security feature(completely or only for the site im using it on) in chrome? I know edge is based on chromium so I expect it to be possible, but am unable to find how/where

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!