Skip to content

Instantly share code, notes, and snippets.

// ==UserScript==
// @name Video CrossOrigin set to anonymous to fix CORS error with video screenshot type Javascript, mainly for Twitch, may be useful for other sites
// @namespace http://tampermonkey.net/
// @version 0.2
// @description try to take over the world!
// @author @tim1986
// @match *://*.twitch.tv/*
// @exclude http://clips.twitch.tv/*
// @exclude https://clips.twitch.tv/*
// @exclude https://www.twitch.tv/*/clip/*
@tballas
tballas / Print Twitch Video.js
Last active May 9, 2018 10:51
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/>";
// "Fixed" Arrow Functions example from
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions
var materials = [
'Hydrogen',
'Helium',
'Lithium',
'Argon',
'Tin',
'',
@tballas
tballas / Youtube Screenshot
Last active April 21, 2016 02:16
Bookmarklet to create Youtube Screenshot to Imgur. To replace youtubescreenshot.com that is kind of broken or not working. You *MUST* be on a youtube video with a timecode in the URL. To get this to work: Replace "INSERT_IMGUR_CLIENTID" with your imgur client id Get it here: https://api.imgur.com/oauth2/addclient
javascript:void function(e){var t=function(e){function t(e){window.open(e.data.link)}var a=document.getElementsByTagName("meta");length=a.length;for(var n=0;n<length;n++)if("og:image"==a[n].getAttribute("property"))var o=a[n].getAttribute("content");var r="INSERT_IMGUR_CLIENTID",i=o;e.ajax({url:"https://api.imgur.com/3/image",type:"POST",datatype:"json",data:{image:i},success:t,error:t,beforeSend:function(e){e.setRequestHeader("Authorization","Client-ID "+r)}})},a=e&&e.fn&&parseFloat(e.fn.jquery)>=1.7;if(a)t(e);else{var n=document.createElement("script");n.src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.js",n.onload=n.onreadystatechange=function(){var e=this.readyState;e&&"loaded"!==e&&"complete"!==e||t(jQuery.noConflict())}}document.getElementsByTagName("head")[0].appendChild(n)}(window.jQuery);