I'm trying to make a Google Chrome Extension that will automatically check the 3rd checkbox (Hansen Dam) on a 3rd party website. I can't seem to get it to work.
Here's the website: https://cityofla.ezlinksgolf.com/index.html#/preSearch
manifest.json
{
"manifest_version": 2,
"name": "Tester",
"version": "1.0.0",
"permissions": ["activeTab"],
"content_scripts": [
{
"matches": ["<all_urls>"],
"all_frames": true,
"js": ["Scripts/content.js"]
}
]
}
content.js
// trying to check the 3rd box directly, method 1
const a=document.querySelectorAll('input[type="checkbox"]');
a[3].checked = true;
// i've tried checking all the boxes with a loop, method 2
var arr = [];
const allInputs = document.getElementsByTagName("input");
for (let i = 0; i < allInputs.length; i++){
if (allInputs[i].type == 'checkbox')
allInputs[i].checked = true;
arr.push(i); // make a new array of only checkboxes, to pick 3rd checkbox from this array
}
// trying another way, method 3
arr[3].checked = true;
Any help appreciated!
Aucun commentaire:
Enregistrer un commentaire