~ posts articles presentations code about

Little myepisodes.com userscript

2012-05-01

As a little project for today to learn some javascript, I decided to modify one of my favourite websites myepisodes.com and make it a little bit more useful, by adding torrent links directly to the show list >:)

Down below is the userscript that will modify the contents of each cell and update the link from tvrage to a torrent search engine.

Installation for Opera:

Go to Preferences > content > javascript options > User javascript folder.

Set a folder to put your user javascripts if you haven't, otherwise add this script to that folder.

// ==UserScript==
// @include http://myepisodes.com/*
// ==/UserScript==

function myfunc()
 {
  // get table by class name as array
 arr = document.getElementsByClassName('showname')

  // loop over array
 for (var i = 0; i < arr.length; i++) {

    // get show name
   var name = arr.item(i).innerText;

    // add torrentz.net search
   var str = "http://torrentz.eu/search?f=" + name.replace(/ /g,"+")

    // generate link
   link = "<a href="+str+">"+name+"</a>"

    // generate 720p link
   link_720p = "<a href="+str+" +720p"+">"+"(720p)"+"</a>"

    // update cell
   arr.item(i).innerHTML = link + " " + link_720p;
  }
 }

 // run after page has loaded
window.onload = myfunc;

Original post on web.archive.org.