So I would like to open a bunch (~25) of hyperlinks from one page.
Each hyperlink contains the text Free Win
.
I simply want each link to open in a new tab in the browser. I've set up my Greasemonkey script like the following, but it only opens the first hyperlink.
var TargetLink = $("a:contains('Free Win')")
if (TargetLink.length)
window.location.href = TargetLink[0].href
Try this if you want to open all the links that is having 'Free Win' as text:
var TargetLink = $("a:contains('Free Win')")
for (var i =0;i<TargetLink.length;i++)
window.open(
TargetLink[i].href,
'_blank' // <- This is what makes it open in a new window.
);