Ripsave - Simple Reddit Video Downloader (with sound)

Lets you download reddit videos with sound using ripsave

Från och med 2019-10-09. Se den senaste versionen.

// ==UserScript==
// @name         Ripsave - Simple Reddit Video Downloader (with sound)
// @namespace    1N07
// @version      0.3.4
// @description  Lets you download reddit videos with sound using ripsave
// @author       1N07
// @require      https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js
// @match        https://www.reddit.com/*
// @exclude      https://www.reddit.com/message/compose/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    var baseUrl = "https://ripsave.com/download?video=";

    AddButtons();
    setInterval(AddButtons, 200);

    function AddButtons() {
        //=== post page ===//
        let target = $("div[data-test-id=post-content] div:not(.addedDLButt) > video");
        if(target.length > 0) {
            let bar = target.parent().parent().parent().next();
            let saveButt = bar.find("button[role=menuitem]:contains('save'):first");
            saveButt.after(saveButt.clone().addClass("downloadVid"));
            let dlButt = bar.find(".downloadVid");
            dlButt.find("i.icon").removeClass("icon-save").addClass("icon-downvote");
            dlButt.find("span:last").html('Download');

            dlButt.click(function(e){
                e.preventDefault();
                let dlUrl = window.location.href.split("#")[0].split("?")[0];
                window.open(baseUrl + dlUrl, "_blank");
            });

            target.parent().addClass("addedDLButt");
        }

        //=== browse page ===//
        let targets = $("div.scrollerItem div:not(.addedDLButt) > video");
        targets.each(function(){
            let bar = $(this).parent().parent().parent().parent().next();
            let saveButt = bar.find("button[role=menuitem]:contains('save'):first");
            saveButt.after(saveButt.clone().addClass("downloadVid"));
            let dlButt = bar.find(".downloadVid");
            dlButt.find("i.icon").removeClass("icon-save").addClass("icon-downvote");
            dlButt.find("span:last").html('Download');

            dlButt.click(function(e){
                e.preventDefault();
                let dlUrl = $(this).parent().parent().prev().prev().find("a[data-click-id=body]:first").prop("href").split("#")[0].split("?")[0];
                window.open(baseUrl + dlUrl, "_blank");
            });

            $(this).parent().addClass("addedDLButt");
        });
    }

})();