0

Ok so the page is a calendar of dates. All of the dates are not available, but every once in a while a date frees up and can be clicked on. My goal is to click on it as soon as it is available. There are a total of 30 dates on one page. This is the source of the button of a date once it is available.

<td class="FULL" valign="TOP" width="20" height="15" align="RIGHT"> 
     <a href="" onclick="javascript:schedule(51629,'4/12/2018'); return false;"> 12</a>
     <br>
     AM
</td>

The same button looks like this the rest of the time:

<td class="NON" valign="TOP" width="20" height="15" align="RIGHT"> 
    12
    <br>
    &nbsp;
</td>

I have to say that i am pretty naive with scripts and know less than any of you who is reading this right now. I have installed an extension to refresh the page every 2 seconds, and I have tried writing this in greasemonkey:

document.querySelector('.onclick="javascript:schedule').click()

That doesnt seem to be working. Any help would be very much appreciated !

Saravanan Sachi
  • 2,572
  • 5
  • 33
  • 42
kinase
  • 9
  • 1
  • See waitForKeyElements. – wOxxOm Apr 12 '18 at 03:39
  • A WFKE selector might be like: `.FULL > a[onclick^='javascript:schedule']`. Are you trying to scalp tickets or similar? – Brock Adams Apr 12 '18 at 03:47
  • thanks ! i wish! I am trying to register for an exam lol. – kinase Apr 12 '18 at 04:41
  • Does that sound about right? waitForKeyElements ("javascript:schedule", clickSaveButton); function clickSaveButton (jNode) { triggerMouseEvent (jNode[0], "click"); } function triggerMouseEvent (node, eventType) { var clickEvent = document.createEvent('MouseEvents'); clickEvent.initEvent (eventType, true, true); node.dispatchEvent (clickEvent); } – kinase Apr 12 '18 at 05:05
  • No. `"javascript:schedule"` should be `".FULL > a[onclick^='javascript:schedule']"` as stated above. – Brock Adams Apr 12 '18 at 17:17
  • Thank you Brock! The good news is that the code works perfectly! The bad news is that my IP is getting blacklisted (captcha is slower and impossible to solve) after one single use of the script. Thus i have to wait 48 hours until Captcha works normally again. Any ideas on how to work around this? – kinase Apr 14 '18 at 02:23

0 Answers0