Created
February 5, 2013 03:35
-
-
Save cletusc/4711948 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name TVLinks Helper | |
// @namespace #Cletus | |
// @description Assists the download of shows from TVLinks. Provides download links and highlights compatible hosts. | |
// @copyright 2011+, Ryan Chatham (http://userscripts.org/users/cletus) | |
// @license Creative Commons; http://creativecommons.org/licenses/by-nc-sa/3.0/ | |
// @icon http://www.gravatar.com/avatar.php?gravatar_id=6875e83aa6c563790cb2da914aaba8b3&r=PG&s=48&default=identicon | |
// | |
// @grant GM_addStyle | |
// | |
// @include http://www.tv-links.eu/*/video-results/* | |
// @include http://www.vidxden.com/* | |
// @include http://www.vidbux.com/* | |
// | |
// @version 1.0.0 | |
// ==/UserScript== | |
var supported = [ | |
'vidxden.com', | |
'vidbux.com' | |
]; | |
var details = { | |
'www.vidxden.com': { | |
selector: 'param[name="src"], #player[flashvars]', | |
func: function (elements) { | |
var element = elements[0]; | |
if (element.nodeName == 'PARAM') { | |
showDownloadLink(element.value); | |
} | |
else if (element.nodeName == 'EMBED') { | |
var val = /file=(.*?)&/.exec(element.getAttribute('flashvars')); | |
showDownloadLink(val[1]); | |
} | |
} | |
}, | |
'www.vidbux.com': { | |
selector: '#player[flashvars]', | |
func: function (elements) { | |
var element = elements[0]; | |
if (element.nodeName == 'PARAM') { | |
showDownloadLink(element.value); | |
} | |
else if (element.nodeName == 'EMBED') { | |
var val = /file=(.*?)&/.exec(element.getAttribute('flashvars')); | |
showDownloadLink(val[1]); | |
} | |
} | |
}, | |
'www.tv-links.eu': { | |
selector: '#table_search a.list', | |
func: function (elements) { | |
GM_addStyle(''+ | |
'.highlighted {'+ | |
' background: #c4cfff !important;'+ | |
' border: 1px solid #00c !important;'+ | |
'}'+ | |
''); | |
for (var i = 0; i < elements.length; i++) { | |
var element = elements[i].querySelector('span.dark span.bold'); | |
// Change out old onclick for a traditional href which goes direct to video. | |
var source = /frameLink\('(.*?)'/.exec(elements[i].getAttribute('onclick')); | |
if (!source) { | |
continue; | |
} | |
source = source[1]; | |
elements[i].onclick = ''; | |
elements[i].href = 'http://www.tv-links.eu/gateway.php?data=' + source; | |
// Highlight if there is support. | |
if (supported.indexOf(element.textContent) >= 0) { | |
elements[i].classList.add('highlighted'); | |
} | |
} | |
} | |
} | |
}; | |
var host = location.host; | |
if (details[host]) { | |
details[host].func(document.querySelectorAll(details[host].selector)); | |
} | |
function showDownloadLink(url) { | |
if (url) { | |
GM_addStyle(''+ | |
'#downloadLink {'+ | |
' position: absolute;'+ | |
' top: 0;'+ | |
' width: 100%;'+ | |
' padding: 10px;'+ | |
' background: #c4cfff;'+ | |
' border-bottom: 1px solid #00c;'+ | |
'}'+ | |
''); | |
var container = document.createElement('div'); | |
container.id = 'downloadLink'; | |
container.innerHTML = '<strong>Download Link:</strong> <a href="' + url + '">' + url + '</a>'; | |
document.body.appendChild(container); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment