Skip to content

Instantly share code, notes, and snippets.

@jelmervdl
Created February 25, 2012 08:35
Show Gist options
  • Save jelmervdl/1907347 to your computer and use it in GitHub Desktop.
Save jelmervdl/1907347 to your computer and use it in GitHub Desktop.
Userscript that links Sickbeard file names to the actual files
// ==UserScript==
// @name Sickbeard clickable links
// @description Sick clicketyclick
// @include http://*/home/displayShow?show=*
// @author Jelmer van der Linde, idea by Nino van Hooff
// @version 1.1
// ==/UserScript==
function findBasePath()
{
var rows = document.querySelectorAll('table.infoTable tr');
for (var i = 0; i < rows.length; ++i)
{
var cells = rows[i].getElementsByTagName('td');
for (var j = 0; j < cells.length; ++j)
{
if (cells[j].innerText.indexOf('Location:') != -1)
return cells[j + 1].innerText;
}
}
throw new Error("Basepath not found");
}
function trim(text)
{
return text.replace(/^\s+/, '').replace(/\s+$/, '');
}
function makeFileURI(relative_path)
{
var base_path = findBasePath(),
text = base_path + '/' + relative_path;
/*
return text.substring(0, 1) != '/'
? 'file:///' + encodeURI(text)
: 'file://' + encodeURI(text);
*/
return text.replace(
'/mnt/data/media/series',
'http://doosje2.local/series/series');
}
Array.prototype.forEach.call(
document.querySelectorAll('.sickbeardTable tbody tr td:nth-child(7)'),
function (cell) {
var file_path = trim(cell.innerText);
if (file_path == '')
return;
cell.innerHTML = '<a href="' + makeFileURI(file_path) + '">' + file_path + '</a>';
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment