Fanfiction.net story link grabber
By: a guest | Mar 20th, 2010 | Syntax:
JavaScript | Size: 0.76 KB | Hits: 166 | Expires: Never
// ==UserScript==
// @include http://www.fanfiction.net/book/Harry_Potter/*
// @author AncientSpirit
// @version 1.0
// ==/UserScript==
// License Public Domain
// 1) get all links
var allLinks = document.getElementsByTagName('a');
// 2) create a new array for the links that we want
var myLinks = [];
// 3) walk through all links and add their addresses to myLinks array only if they match
for (var i = 0; i < allLinks.length; i++) {
if (allLinks[i].href.match(/\/s\/.*\/1\//)) {
myLinks.push(allLinks[i].href);
}
}
// 4) create a new div element, insert it into the document and display the links there
document.body.insertBefore(document.createElement('div'), document.body.firstChild).innerHTML = myLinks.join('<br>');