Greasy Fork

Greasy Fork is available in English.

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.

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name       Force HTML 5 for Imgur and Gfycat on Reddit
// @namespace  https://reddit.com/
// @version    1.3.1
// @description Converts giant.gfycat.com hyperlinks to their HTML 5 video counterpart and Imgur links to their HTML 5 video counterpart.
// @include    https://*.reddit.*
// @include    *imgur.com/*
// @copyright  2017
// @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');
   a.href = a.href.replace(/fat\.(.*)\.gif/i, '$1');
   a.href = a.href.replace('/gifs/detail/', '/');
    
   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');
    a.href = a.href.replace('.mp4', '.gifv');
   }
  });
}