How to trigger an ‘isTrusted=true’ click event using JavaScript?

前端 未结 2 502
名媛妹妹
名媛妹妹 2020-12-02 23:00

I\'m trying to impersonate user clicks and mouse movements using a Chrome extension.

For example:
In my content script there is a button click.



        
2条回答
  •  暖寄归人
    2020-12-02 23:45

    You can inject trusted events using the debugger interface.

    chrome.debugger.attach(target, "1.2", function() {
        chrome.debugger.sendCommand(target, "Input.dispatchMouseEvent", arguments)
    })
    

    https://developer.chrome.com/extensions/debugger

    https://chromedevtools.github.io/devtools-protocol/1-2/Input

提交回复
热议问题