Reddit Video Downloader

Allows you to download videos from reddit easily!

当前为 2019-07-02 提交的版本,查看 最新版本

// ==UserScript==
// @name         Reddit Video Downloader
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Allows you to download videos from reddit easily!
// @author       You
// @match        https://www.reddit.com/r/*
// @grant        none
// @run-at       document-idle
// ==/UserScript==

(function() {
    'use strict'
    window.setInterval(function(){
        try {
            const a = document.getElementById('downloadfromplugin').id;
        } catch(e) {
            try {
                const videolink = window.location.href;
                const buttonZone = document.querySelectorAll('[role="menu"]')[0];
                buttonZone.innerHTML += `<button id="downloadfromplugin" class="_2snJGyyGyyH38duHobOUKE m9hgq8-2 dAQykt b1zwxr-0 hxpTao" role="menuitem"><span class="m9hgq8-0 inRMrM"><i class="icon icon-embed _3MSdPVJwGxrpakz-e1MQhO s1htoir6-0 bpvrMF"></i></span><span class="m9hgq8-1 dRGkl">Download!</span></button>`;
                const added = document.getElementById('downloadfromplugin');

                added.addEventListener('click', function () {
                    window.location.href = videolink.replace("reddit", "redditdl");
                });
            } catch(error) {}
        }
    }, 200);
})();