Tag Archive for 'TVsubtitles'

My Greasemonkey script for TVsubtitles

I’m often going to TVsubtitles to download subtitles for TV shows episodes. But the original page doesn’t provide an optimized flow: for example, on the home page there are two sections called “Latest subtitles” and “Most downloaded subtitles”, but they don’t link to the subtitle files. Instead they link to intermediate nagging pages where you then can download the subtitles.

For example, today it appears like this:

tvsub00

Without Greasemonkey script

the Weeds 5×01 doesn’t link to the subtitle file, but links actually to an intermediate page:

tvsub01

Intermediate (and useless) download page

To remediate this and get direct download links, I’ve made the following Greasemonkey script:

// ==UserScript==
// @name           tvsubtitles.net
// @namespace      tvsubtitles.net
// @description    tvsubtitles.net
// @include        http://www.tvsubtitles.net/*
// ==/UserScript==

// http://www.tvsubtitles.net/subtitle-63109.html (/subtitle-) -->
// http://www.tvsubtitles.net/download-63109.html (/download-)

var allLinks, thisLink;

xpath = '//a[contains(@href, "subtitle-")]';

allLinks = document.evaluate(xpath,document,
    null,
    XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,
    null);

for (var i = 0; i < allLinks.snapshotLength; i++) {
	thisLink = allLinks.snapshotItem(i);
	thisLink.href = thisLink.href.replace(/subtitle-/,  "download-");

	if( thisLink.title != "" ) {
	   thisLink.firstChild.textContent = thisLink.firstChild.textContent + " (" + thisLink.title + ")";
	}
}

With that script, the link to the intermediate page is replaced by a link to the subtitle file, and some information about the release corresponding to that sub file is also added:

tvsub02

Using my Greasemonkey script

UPDATE: I’ve just seen that there are 2 similar existing scripts on userscripts.org. At least mine is the only one that add the Release info to the links ;-).




Close
Powered by ShareThis