Greasy Fork is available in English.

Imgur Gifvs to MP4 in Reddit

Replaces Imgur links to video on Reddit

このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください。
// ==UserScript==
// @name                Imgur Gifvs to MP4 in Reddit
// @name:pt-BR          Imgur Gifvs para MP4 no Reddit
// @namespace           https://greasyfork.org/users/821661
// @version             12.7.2
// @description         Replaces Imgur links to video on Reddit
// @description:pt-BR   Substitui Imgur links para video no Reddit
// @grant               GM_addStyle
// @author              hdyzen
// @match               https://www.reddit.com/*
// @match               https://new.reddit.com/*
// @license             MIT
// ==/UserScript==
'use strict';

function createVideo(element) {
    const src = element.href;
    const video = document.createElement('video');
    video.src = src.replace('.gifv', '.mp4');
    video.controls = true;
    video.loop = true;
    video.classList.add('videoGifv');

    video.onerror = e => {
        e.target.outerHTML = `<img src="https://i.imgur.com/removed.png" style="margin: 0 auto; border: 1px solid crimson;" >`;
    };

    element.replaceWith(video);
}

const observer = new MutationObserver(() => {
    const linksGifv = document.querySelectorAll('.Post a[class][href$=".gifv"]');
    linksGifv.forEach(createVideo);
});
observer.observe(document.body, { childList: true });

GM_addStyle(`.videoGifv { height: 80vh; width: 100%; border-radius: 5px; margin: 10px auto 0 auto; background: #000; } ._2i5O0KNpb9tDq0bsNOZB_Q { width: 100%; }`);