Force HTML 5 for Imgur and Gfycat on Reddit

Converts giant.gfycat.com hyperlinks to their HTML 5 video counterpart and Imgur links to their HTML 5 video counterpart.

Version vom 29.06.2016. Aktuellste Version

Du musst eine Erweiterung wie Tampermonkey, Greasemonkey oder Violentmonkey installieren, um dieses Skript zu installieren.

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.

Sie müssten eine Skript Manager Erweiterung installieren damit sie dieses Skript installieren können

(Ich habe schon ein Skript Manager, Lass mich es installieren!)

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       Force HTML 5 for Imgur and Gfycat on Reddit
// @namespace  https://reddit.com/
// @version    1.1
// @description Converts giant.gfycat.com hyperlinks to their HTML 5 video counterpart and Imgur links to their HTML 5 video counterpart.
// @include    https://www.reddit.com/*
// @include    *imgur.com/*
// @copyright  2016
// @grant metadata
// ==/UserScript==

document.addEventListener('DOMContentLoaded', changeGif, false);
if (document.readyState === 'complete') {
  changeGif();
}

document.addEventListener("contextmenu", changeGif);
document.addEventListener("click", changeGif);

function changeGif() {

  Array.forEach(document.links, function (a) {
    a.href = a.href.replace(/giant\.(.*)\.gif/i, '$1');
    a.href = a.href.replace(/giant\.(.*)\.webm/i, '$1');
    a.href = a.href.replace(/giant\.(.*)\.mp4/i, '$1');
  });
  
  Array.forEach(document.links, function (a) {
    a.href = a.href.replace(/fat\.(.*)\.gif/i, '$1');
  });

 Array.forEach(document.links, function (a) {
  if(a.href.indexOf(".imgur.com")>-1 || a.href.indexOf("/imgur.com")>-1){
   a.href = a.href.replace('.gif', '.gifv');
   a.href = a.href.replace('.gifvv', '.gifv');
  }
 });
}