Skip to content

Instantly share code, notes, and snippets.

@ooobo
Last active June 22, 2019 08:00
Show Gist options
  • Save ooobo/435621d4001d8531c5f8993ac89089ef to your computer and use it in GitHub Desktop.
Save ooobo/435621d4001d8531c5f8993ac89089ef to your computer and use it in GitHub Desktop.
tveeder + timestamps and live updating captions everywhere
<p><a href="javascript:location.href.match(%2Ftveeder%2F)%3F(%24(%22.caption%22).each(function(a)%7Ba%3D%24(this).attr(%22data-date%22)%3Ba%3D(new%20Date(1E3*a)).toLocaleString()%3B%24(this).attr(%22title%22%2Ca)%7D)%2C%24(%22%23caption-container%22).on(%22DOMNodeInserted%22%2C%22.caption%22%2Cfunction(a)%7Ba%3D%24(%22.caption%22).last()%3Bvar%20b%3Da.attr(%22data-date%22)%3Bb%3D(new%20Date(1E3*b)).toLocaleString()%3Ba.attr(%22title%22%2Cb)%7D)%2C%22undefined%22!%3Dtypeof%20x%3FDate.now()%2F1E3%3Cx.to%3F(console.log(%22program%20still%20airing%2C%20grab%20live%20captions%22)%2CgetCaptions())%3Aconsole.log(%22program%20finished%22)%3Aconsole.log(%22live%20already%2C%20do%20not%20trigger%20getCaptions%22))%3Awindow.location%3D%22http%3A%2F%2Ftveeder.com%22%3Bvoid+0">tveeder+</a></p>
<p>drag that link to your bookmarks bar, click it when to visit tveeder.com, then <b>click again</b> for timestamps on hover over captions, and updating captions on program pages accessed through the epg.</p>
// check if on tveeder already, if not, load it.
if(!location.href.match(/tveeder/)) {window.location='http://tveeder.com' } else {
// write timestamp for every caption on page
$('.caption').each(
function(index) {
var a = $(this).attr('data-date');
var b = new Date(a*1000).toLocaleString();
$(this).attr('title',b);
});
// if new captions are added, give them timestamps too
$('#caption-container').on('DOMNodeInserted','.caption', function(a) {
var a = $('.caption').last();
var b = a.attr('data-date');
var c = new Date(b*1000).toLocaleString();
a.attr('title',c);
});
// if program is still live (i.e. time now < end of byrange), keep adding captions
if (typeof x != "undefined") {
if (Date.now()/1000 < x.to) {
console.log('program still airing, grab live captions');
getCaptions();
}
else{ console.log('program finished'); }
}
else{ console.log('live already, do not trigger getCaptions'); }
}
@ooobo
Copy link
Author

ooobo commented Sep 26, 2016

go to this link to easily add the bookmarklet

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment