I am using Greasemonkey to inject some Javascript code into a webpage that I want to auto-refresh and automatically download interesting files from. I have everything working other than the downloading of the file.
I have found the interesting table cell that contains the download link. How do I follow that link to download the file? (I have FF set to always download the type of file to a directory on my drive).
The table cell contents look like:
<td class="rowhead" align="center">
<a href="download.php/576537/O%26A%205-16-14.bin?passkey=5bb50ef2d99baebc29190291157a8b43">
[
<b>DL</b>
]
</a>
</td>
I have no way of editing the webpage as it is a public forum.
Thanks
ADDED Code which almost works:
// skip first as it isnt valid
var rows = mainTable[0].tBodies[0].rows;
for (var row = 1; row < rows.length; row++)
{
var cells = rows[row].cells;
var Title = cells[1].innerHTML.toLowerCase();
if (IsTitleMatchAnyRule(Rules, Title))
{
// this shows me the link which it will attempt to download
alert(cells[3].querySelector('a '));
//This works for a single link in the whole page
//location.href = cells[3].querySelector('a ');
cells[3].addEventListener("click",function(e){
var link = this.querySelector('a ');
// I never see this alert - commenting out doesnt download the link either
alert(link);
location.href = link;
},false);
}
}