I don't know anything about writing code but I'm trying to write a script to automatically block people on Instagram but I'm having trouble because the report button and block buttons have the same name.
<button class="aOOlW -Cab_ " tabindex="0">Report User</button>
<button class="aOOlW -Cab_ " tabindex="0">Block this user</button>
If I use "aOOlW -Cab_" then it just clicks the report button over and over again and if I use the whole class then it doesn't click on anything.
Any help is appreciated
You can search for the correct button by checking for the text of each button with something like this:
var btns = document.getElementsByClassName("aOOlW");
for (var i = 0; i < btns.length; i++) {
if (btns[i].innerHTML == "Block this user") {
btns[i].click();
}
}
This is assuming the buttons aren't a part of your own code. If they are a part of your own code, you can just add id tags to them like this:
<button class="aOOlW -Cab_ " id="report" tabindex="0">Report User</button>
<button class="aOOlW -Cab_ " id="block" tabindex="0">Block this user</button>
And get the correct button with:
document.getElementById("block");