I'm using Greasekit so need this to be in Javascript.
I want to be able to automatically click the link where it says 25
below. However, the link is not always 25, it is sometimes (say) 21 or 26 (depending on how long the newsletter is).
What remains constant is that the link is always in the same position / place on the page. It is ALWAYS the one before Next >
and 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 I was saying... the link is not always 25, it is sometimes (say) 13 or 29 (depending on how long the newsletter is).
What remains constant is that the link is always in the same position / place on the page. It is ALWAYS the one before Next >
and after 3
Can I, using code, always find and then click on the appropriate link?
If i was instructing human
I would start by saying to find table class v_page_nav
Then, scan your eyes right and look for the link Next >
. Click the link that immediately precedes it: it will always be a number (and that number will always be higher than the numbers on the left of it).
How do I achieve the same thing in code?