So i have a school issue where i need to access a site but this site requires me to go through around 4 portals to get there and am hoping to just write a quick script to do this for me. Problem comes where the site is very sloppy and are written with names being the same on certian buttons so I would like to click the buttons based on class
the classes are readit2, readit23, readit239, and readit2394
$(function(){
document.getElementByClassName(readit2).click();
});
the above code i thought would click it as soon as it loads the first page but does not. any help would be great
// ==UserScript==
// @name dumb spider web
// @namespace ===============
// @version 0.1
// @description gets me through this dumb stuff
// @match ===============
// @copyright 2012+, You
// @require http://code.jquery.com/jquery-latest.js
// ==/UserScript==
edit ^ added the header stuff
more edits:
it works through the console now but through tamper monkey OR grease monkey I can not get it to actually preform the action.
$(function(){
document.getElementsByClassName("readit2")[0].click();
});
Works through console but does not run when script is started.
I started looking at all the wrong things, your original code:
$(function(){
document.getElementByClassName(readit2).click();
});
The issue with this is that the call should be getElementsByClassName
(plural "Elements"), since class is usually a shared property. That also returns an array, so if you are positive that there is only 1 ever:
$(function(){
document.getElementsByClassName("readit2")[0].click();
});
If not, I'd suggest getting the text and verifying that it contains something that you expect.
Edit: Added quotes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With