Skip to content

Instantly share code, notes, and snippets.

@tballas
Last active May 9, 2018 10:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tballas/22427a5131aa7d9ef8221fb344394dec to your computer and use it in GitHub Desktop.
Save tballas/22427a5131aa7d9ef8221fb344394dec to your computer and use it in GitHub Desktop.
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