I'm currently trying to make a TamperMonkey/GreaseMonkey script to enter some info/click some buttons.
The site doesn't use IDs for pretty much anything, mainly only class names. I managed to figure out how to input info but I can't manage to figure out how to click a button that has multiple classes.
Here's an example of a button that I'm trying to click:
<button type="submit" class="btn btn-success btn-lg btn-block btn-submit waves-effect waves-light">Save</button>
Here's my most recent attempt at clicking it:
document.getElementsByClassName(".btn.btn-success.btn-lg.btn-block.btn-submit.waves-effect.waves-light")[0].click();
I've tried a few different suggestions from here on StackOverflow but they don't seem to be working. Not really sure what else to do. I'd appreciate some help, thanks.
Ok... You mix jQuery and JavaScript syntax here.
If if want it in JavaScript, this should work:
(So you won't have to load jQuery in GreaseMonkey)
document.getElementsByClassName(" btn btn-success btn-lg btn-block btn-submit waves-effect waves-light")[0].click();
«names is a string representing the list of class names to match; class names are separated by whitespace» Reference
If you want it in jQuery:
$(".btn.btn-success.btn-lg.btn-block.btn-submit.waves-effect.waves-light").first().click();