Share Pastebin
Guest
Public paste!

Fanfiction.net story link grabber

By: a guest | Mar 20th, 2010 | Syntax: JavaScript | Size: 0.76 KB | Hits: 166 | Expires: Never
This paste has a previous version, view the difference. Copy text to clipboard
  1. // ==UserScript==
  2. // @include   http://www.fanfiction.net/book/Harry_Potter/*
  3. // @author    AncientSpirit
  4. // @version   1.0
  5. // ==/UserScript==
  6. // License    Public Domain
  7.  
  8. // 1) get all links
  9.  
  10. var allLinks = document.getElementsByTagName('a');
  11.  
  12. // 2) create a new array for the links that we want
  13.  
  14. var myLinks = [];
  15.  
  16. // 3) walk through all links and add their addresses to myLinks array only if they match
  17.  
  18. for (var i = 0; i < allLinks.length; i++) {
  19.    if (allLinks[i].href.match(/\/s\/.*\/1\//)) {
  20.       myLinks.push(allLinks[i].href);
  21.    }
  22. }
  23.  
  24. // 4) create a new div element, insert it into the document and display the links there
  25.  
  26. document.body.insertBefore(document.createElement('div'), document.body.firstChild).innerHTML = myLinks.join('<br>');