javascript - How to autoclick that is in this set position (of a known table class) -
i'm using greasekit need in javascript.
i want able automatically click link says 25
below. however, the link not 25, (say) 21 or 26 (depending on how long newsletter is). remains constant link in same position / place on page. 1 before next >
, after 3
<table class="v_page_nav" border="0" cellpadding="5" cellspacing="0" width="100%"> <tr> <td width="100%">showing 1-25 of 610 results</td> <td><span style="color: #999999">< previous</span> | page:</td> <td class="on"> <a href="/wine/newsletter?ie=utf8&page=1" id="pagination-page-1">1</a></td> <td class="off"> <a href="/wine/newsletter?ie=utf8&page=2" id="pagination-page-2">2</a></td> <td class="off"> <a href="/wine/newsletter?ie=utf8&page=3" id="pagination-page-3">3</a></td> <td>...</td> <td> <a href="/wine/newsletter?ie=utf8&page=25" id="pagination-page-25">25</a></td> <td>| <a href="/wine/newsletter?ie=utf8&page=2" id="pagination-next-link">next ></a> </td> </tr> </table>
as saying... the link not 25, (say) 13 or 29 (depending on how long newsletter is). remains constant link in same position / place on page. 1 before next >
, after 3
can i, using code, find , click on appropriate link?
if instructing human
i start saying find table class v_page_nav
then, scan eyes right , link next >
. click link precedes it: number (and number higher numbers on left of it).
how achieve same thing in code?
get of anchors on page, loop through them, return 1 right before "next"
function getpreviouslink(){ var nextlink = document.getelementbyid('pagination-next-link'); var links = document.getelementsbyclassname('v_page_nav')[0].getelementsbytagname("a"); for(var i=0; < links.length; i++){ if(links[i] == nextlink) { return links[i-1]; } } }
Comments
Post a Comment