Download from www.redgifs.com

Adds a download button to each video.

このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください。
// ==UserScript==
// @name        Download from www.redgifs.com
// @namespace   Violentmonkey Scripts
// @match       https://www.redgifs.com/*
// @grant       none
// @version     1.01
// @author      ape-that-presses-keys
// @license     MIT
// @description Adds a download button to each video.
// ==/UserScript==

function dl() {
    let i = document.querySelector("img.Player-Poster").src;
    let u = i.substring(0, i.length - 11);
    if (document.querySelector("video").src.substring(0, 4) == "blob") {
        u = u + ".m4s";
    } else {
        u = u + ".mp4";
    }
    window.open(u, "_blank");
}

let dl_button = document.createElement("button");
dl_button.id = "redgifs_dl_button";
dl_button.onclick = dl;
dl_button.innerText = "DL";

let append_dl_button_interval = setInterval(() => {
    let parent_element = document.querySelector(".GifPreview-SideBarWrap");
    let dl_button_exists = document.querySelector("#redgifs_dl_button");
    // add dl button if the DOM nodes we use currently exist and it's not already added
    if (parent_element && !dl_button_exists) {
        document.querySelector(".GifPreview-SideBarWrap").appendChild(dl_button);
    }
}, 500);