im trying to click a simple button at https://clickspeedtest.com/ but i keep getting the error "Uncaught TypeError: Cannot read property 'click' of undefined", this is my code:
manifest.json
{
"name": "test",
"version": "1.0",
"manifest_version": 3,
"content_scripts": [
{
"all_frames": true,
"matches": [ "http://*/*", "https://*/*" ],
"js": ["content.js"],
"run_at": "document_end"
}
],
"permissions": [ "\u003Call_urls>" ]
}
content.js
function myFunction() {
var myEle = document.getElementsByClassName("rbutton");
if(myEle){
myEle.click();
}
}
myFunction()
I hope this will works for you. Please try this myEle.dispatchEvent(new MouseEvent('click'))
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.