-
-
Save trivoallan/461375 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
var s=document.createElement('script'); | |
s.setAttribute('src','http://jquery.com/src/jquery-latest.js'); | |
document.getElementsByTagName('body')[0].appendChild(s); | |
function jqueryWait() { | |
if(typeof window.jQuery == 'undefined') { | |
window.setTimeout(jqueryWait,100); | |
} else{ | |
$ = window.jQuery; | |
doJQuery(); | |
} | |
} | |
function doJQuery() { | |
// Make a call to URIplay to get the current page's brand and latest episodes | |
// Restrict the returned media locations by a location (try 'us' and 'uk') | |
var pageTitle = urlencode($('#profile_name').text()); | |
var currentLocation = 'us'; | |
$.getJSON('http://api.uriplay.org/2.0/brands.json?title='+pageTitle+'&availableCountries='+currentLocation+'&limit=1&callback=?', | |
function(data) { | |
// Don't do anything if the tv_show isn't available in the current country | |
if (data && data.playlists && data.playlists[0]) { | |
// Get the latest episode | |
var latestEpisode = data.playlists[0].items[0]; | |
var embedLocation = null; | |
var linkLocation = null; | |
// Retrieve the embedable media location along with the broadcaster's playback page | |
for (i=0;i<latestEpisode.locations.length;i++) { | |
var location = latestEpisode.locations[i]; | |
if (location.transport_type == 'embed') { | |
embedLocation = location; | |
} else if (location.transport_type == 'link') { | |
linkLocation = location | |
} | |
} | |
var linkOff = (linkLocation && latestEpisode.publisher | |
? "<br /><a href='"+linkLocation.uri+"' target='_blank'>Watch it on "+latestEpisode.publisher+"</a>" | |
: ""); | |
var videoLink = (embedLocation | |
? "<a id='uriplay_video' style='margin-left:30px' class='uiVideoThumb'>" | |
: "<a href='"+linkLocation.uri+"'style='margin-left:30px' target='_blank' class='uiVideoThumb'>"); | |
var titleHtml = "<h5 class='box_header UITitle UITitle_h5'>Latest Episode</h5><p style='padding:5px;'><strong>"+latestEpisode.title+"</strong></p>"; | |
var videoHtml = videoLink+"<img src='"+latestEpisode.image+"' /><i></i></a>"; | |
var descriptionHtml = "<p style='padding:5px;'>"+latestEpisode.description+linkOff+"</p>"; | |
var moduleHtml = "<div class='box basic_info_summary'>"+titleHtml+videoHtml+descriptionHtml+"</div>"; | |
var parentElement = $('#profile_blurb'); | |
if (!parentElement.length) { | |
parentElement = $('#basic_info_summary_box'); | |
} | |
parentElement.parent().prepend(moduleHtml); | |
$('#uriplay_video').click(function() { | |
var videoSrc="<div id='uriplay_embeded_video'>"+embedLocation.embed_code+"</div>"; | |
if ($('#uriplay_embeded_video').length) { | |
$('#uriplay_embeded_video').remove(); | |
} | |
$(videoSrc).prependTo('#pagelet_tab_content'); | |
return false; | |
}); | |
} | |
}); | |
} | |
function urlencode(str) { | |
return escape(str).replace('+', '%2B').replace('%20', '+').replace('*', '%2A').replace('/', '%2F').replace('@', '%40'); | |
} | |
jqueryWait(); |
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
javascript:var%20s=document.createElement(%27script%27);s.setAttribute(%27src%27,%27http://jquery.com/src/jquery-latest.js%27);document.getElementsByTagName(%27body%27)[0].appendChild(s);function%20jqueryWait()%20{if(typeof%20window.jQuery%20==%20%27undefined%27)%20{window.setTimeout(jqueryWait,100);}%20else{$%20=%20window.jQuery;doJQuery();}}function%20doJQuery()%20{var%20pageTitle%20=%20urlencode($(%27#profile_name%27).text());var%20currentLocation%20=%20%27us%27;$.getJSON(%27http://api.uriplay.org/2.0/brands.json?title=%27+pageTitle+%27&availableCountries=%27+currentLocation+%27&limit=1&callback=?%27,function(data)%20{if%20(data%20&&%20data.playlists%20&&%20data.playlists[0])%20{var%20latestEpisode%20=%20data.playlists[0].items[0];var%20embedLocation%20=%20null;var%20linkLocation%20=%20null;for%20(i=0;i<latestEpisode.locations.length;i++)%20{var%20location%20=%20latestEpisode.locations[i];if%20(location.transport_type%20==%20%27embed%27)%20{embedLocation%20=%20location;}%20else%20if%20(location.transport_type%20==%20%27link%27)%20{linkLocation%20=%20location}}var%20linkOff%20=%20(linkLocation%20&&%20latestEpisode.publisher?%20%22<br%20/><a%20href=%27%22+linkLocation.uri+%22%27%20target=%27_blank%27>Watch%20it%20on%20%22+latestEpisode.publisher+%22</a>%22:%20%22%22);var%20videoLink%20=%20(embedLocation?%20%22<a%20id=%27uriplay_video%27%20style=%27margin-left:30px%27%20class=%27uiVideoThumb%27>%22:%20%22<a%20href=%27%22+linkLocation.uri+%22%27style=%27margin-left:30px%27%20target=%27_blank%27%20class=%27uiVideoThumb%27>%22);var%20titleHtml%20=%20%22<h5%20class=%27box_header%20UITitle%20UITitle_h5%27>Latest%20Episode</h5><p%20style=%27padding:5px;%27><strong>%22+latestEpisode.title+%22</strong></p>%22;var%20videoHtml%20=%20videoLink+%22<img%20src=%27%22+latestEpisode.image+%22%27%20/><i></i></a>%22;var%20descriptionHtml%20=%20%22<p%20style=%27padding:5px;%27>%22+latestEpisode.description+linkOff+%22</p>%22;var%20moduleHtml%20=%20%22<div%20class=%27box%20basic_info_summary%27>%22+titleHtml+videoHtml+descriptionHtml+%22</div>%22;var%20parentElement%20=%20$(%27#profile_blurb%27);if%20(!parentElement.length)%20{parentElement%20=%20$(%27#basic_info_summary_box%27);}parentElement.parent().prepend(moduleHtml);$(%27#uriplay_video%27).click(function()%20{var%20videoSrc=%22<div%20id=%27uriplay_embeded_video%27>%22+embedLocation.embed_code+%22</div>%22;if%20($(%27#uriplay_embeded_video%27).length)%20{$(%27#uriplay_embeded_video%27).remove();}$(videoSrc).prependTo(%27#pagelet_tab_content%27);return%20false;});}});}function%20urlencode(str)%20{return%20escape(str).replace(%27+%27,%20%27%2B%27).replace(%27%20%27,%20%27+%27).replace(%27*%27,%20%27%2A%27).replace(%27/%27,%20%27%2F%27).replace(%27@%27,%20%27%40%27);}jqueryWait(); |
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
javascript:var%20s=document.createElement(%27script%27);s.setAttribute(%27src%27,%27http://jquery.com/src/jquery-latest.js%27);document.getElementsByTagName(%27body%27)[0].appendChild(s);function%20jqueryWait()%20{if(typeof%20window.jQuery%20==%20%27undefined%27)%20{window.setTimeout(jqueryWait,100);}%20else{$%20=%20window.jQuery;doJQuery();}}function%20doJQuery()%20{var%20pageTitle%20=%20urlencode($(%27#profile_name%27).text());var%20currentLocation%20=%20%27uk%27;$.getJSON(%27http://api.uriplay.org/2.0/brands.json?title=%27+pageTitle+%27&availableCountries=%27+currentLocation+%27&limit=1&callback=?%27,function(data)%20{if%20(data%20&&%20data.playlists%20&&%20data.playlists[0])%20{var%20latestEpisode%20=%20data.playlists[0].items[0];var%20embedLocation%20=%20null;var%20linkLocation%20=%20null;for%20(i=0;i<latestEpisode.locations.length;i++)%20{var%20location%20=%20latestEpisode.locations[i];if%20(location.transport_type%20==%20%27embed%27)%20{embedLocation%20=%20location;}%20else%20if%20(location.transport_type%20==%20%27link%27)%20{linkLocation%20=%20location}}var%20linkOff%20=%20(linkLocation%20&&%20latestEpisode.publisher?%20%22<br%20/><a%20href=%27%22+linkLocation.uri+%22%27%20target=%27_blank%27>Watch%20it%20on%20%22+latestEpisode.publisher+%22</a>%22:%20%22%22);var%20videoLink%20=%20(embedLocation?%20%22<a%20id=%27uriplay_video%27%20style=%27margin-left:30px%27%20class=%27uiVideoThumb%27>%22:%20%22<a%20href=%27%22+linkLocation.uri+%22%27style=%27margin-left:30px%27%20target=%27_blank%27%20class=%27uiVideoThumb%27>%22);var%20titleHtml%20=%20%22<h5%20class=%27box_header%20UITitle%20UITitle_h5%27>Latest%20Episode</h5><p%20style=%27padding:5px;%27><strong>%22+latestEpisode.title+%22</strong></p>%22;var%20videoHtml%20=%20videoLink+%22<img%20src=%27%22+latestEpisode.image+%22%27%20/><i></i></a>%22;var%20descriptionHtml%20=%20%22<p%20style=%27padding:5px;%27>%22+latestEpisode.description+linkOff+%22</p>%22;var%20moduleHtml%20=%20%22<div%20class=%27box%20basic_info_summary%27>%22+titleHtml+videoHtml+descriptionHtml+%22</div>%22;var%20parentElement%20=%20$(%27#profile_blurb%27);if%20(!parentElement.length)%20{parentElement%20=%20$(%27#basic_info_summary_box%27);}parentElement.parent().prepend(moduleHtml);$(%27#uriplay_video%27).click(function()%20{var%20videoSrc=%22<div%20id=%27uriplay_embeded_video%27>%22+embedLocation.embed_code+%22</div>%22;if%20($(%27#uriplay_embeded_video%27).length)%20{$(%27#uriplay_embeded_video%27).remove();}$(videoSrc).prependTo(%27#pagelet_tab_content%27);return%20false;});}});}function%20urlencode(str)%20{return%20escape(str).replace(%27+%27,%20%27%2B%27).replace(%27%20%27,%20%27+%27).replace(%27*%27,%20%27%2A%27).replace(%27/%27,%20%27%2F%27).replace(%27@%27,%20%27%40%27);}jqueryWait(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment