Tuesday, 1 May 2012

Little myepisodes.com userscript

As a little project for today to learn some javascript, I decided to modify one of my favourite websites <a href="www.myepisodes.com">myepisodes.com</a> 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
   var link = ""+name+"" 
    // generate 720p link
   var link_720p = ""+"(720p)"+""
    // update cell
   arr.item(i).innerHTML = link + " " + link_720p; 

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