GfyCat Redirect to WebM Video File

Automatically promotes GfyCat gif pages to raw WebM video

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         GfyCat Redirect to WebM Video File
// @namespace    gfycatVideoRedirect_kk
// @description  Automatically promotes GfyCat gif pages to raw WebM video
// @version      0.2
// @author       Kai Krause <[email protected]>
// @match        http://gfycat.com/*
// @match        https://gfycat.com/*
// @grant       none
// @run-at       document-end
// ==/UserScript==

// gifycat.com/gifs/detail/id
var videoPlayer = document.getElementsByTagName('video')[0];
if (videoPlayer) {
	var children = videoPlayer.childNodes;
	for (var i = 0; i < children.length; ++i) {
		if (children[i].type == "video/webm") {
			var webm = children[i].src;
			break;
		}
	}
} else {
	// gifycat.com/id
	var webm = document.getElementById('webmSource').src;
	var mp4 = document.getElementById('mp4Source').src;
}

if (webm) {
	location.assign(webm);
} else if (mp4) {
	location.assign(mp4);
}