Create a gist now

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Print Twitch Video Bookmarklet, based off of the same for Youtube from http://labnol.org/?p=28217
javascript:(function() {
a = document.querySelector('meta[property="og:video:duration"').content;
if (!a) {
alert("Sorry we cannot process this Twitch video. Could you please try another one");
exit();
}
var base_url = "https://vod-storyboards.twitch.tv/" + /vods\/(.*?)\//.exec(document.querySelector('meta[property="og:image"').content)[1] + "/storyboards/" + /\/videos\/(.*?)$/.exec(document.querySelector('meta[property="og:url"').content)[1] + "-high-";
var imgs = "";
for (i = 0; i < 4; i++) {
imgs += "<PICTURE='"+base_url+i+".jpg'><br/>";
}
var title = document.querySelector('meta[property="og:title"').content;
msg = "<body style='background-color:#444;color:#eee;margin:20px auto;width:90%;text-align:center'><h2>TITLE</h2><div>IMAGES</div><br/><em>Printed using the Twitch bookmarklet.<br/><a href='http://labnol.org/?p=28217' style='text-decoration:none;color:#fff;font-style:bold'>Based off of bookmarklet from labnol.</a></em></body>";
msg = msg.replace("TITLE", title).replace("IMAGES", imgs).replace(/PICTURE/g, "img src");
var labnol = window.open();
labnol.document.open();
labnol.document.write(msg);
labnol.document.close();
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment