您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Adds button to direct link or download the stupidly hard to save or share directly reddit videos. Designed to work on new Reddit only. Buttons appear when viewing the specific post -- does not work on preview/expand on post listing pages.
当前为
// ==UserScript== // @name Reddit Video Downloader // @namespace https://lawrenzo.com/p/reddit-video-downloader // @version 0.5.1 // @description Adds button to direct link or download the stupidly hard to save or share directly reddit videos. Designed to work on new Reddit only. Buttons appear when viewing the specific post -- does not work on preview/expand on post listing pages. // @author Lawrence Sim // @license WTFPL (http://www.wtfpl.net) // @grant none // @match *://*.reddit.com/* // ==/UserScript== 'use strict'; (function() { var defaultStyles = { "margin": "0.4em", "font-size": "0.8em", "padding": "0.4em 0.6em", "border-radius": "4px", "border": "1px solid #d9d9d9", "background": "#fff", "cursor": "pointer" }; function createBtn(parent, opts) { let btn = document.createElement("button"); btn.innerHTML = opts.html; for(let key in defaultStyles) { btn.style[key] = defaultStyles[key]; } if(opts.disabled) { btn.disabled = true; btn.style.background = "#bbb"; btn.style.cursor = "wait"; } if(opts.href) btn.addEventListener('click', () => window.open(opts.href)); parent.append(btn); return btn; } function addLinks() { let contentDiv = document.querySelector("[data-test-id='post-content']"), videoElem = contentDiv && contentDiv.querySelector("video"); if(!videoElem || videoElem.getAttribute("vlinked")) return; let directBtn = createBtn(contentDiv, { html: "Direct Video Link (no sound)", disabled: true }); createBtn(contentDiv, { href: window.location.href.replace(/reddit.com\//, "redditsave.com/info?url="), html: "Download via RedditSave" }); createBtn(contentDiv, { href: window.location.href.replace(/reddit.com/, "reddit.tube"), html: "Download via Reddit.Tube" }); videoElem.setAttribute("vlinked", 1); fetch(window.location.href.split("?")[0].replace(/\/$/, "")+".json") .then(res => { if(!res || !res.ok) throw Error((res && res.statusText) || "Fetch error"); return res.json(); }) .then(json => { let postData, vidData; try { postData = json[0].data.children[0].data; if(!postData.secure_media && postData.crosspost_parent_list && postData.crosspost_parent_list.length) { postData = postData.crosspost_parent_list[0]; } vidData = postData.secure_media.reddit_video; } catch(e) { } if(!vidData) return console.log(postData || json); console.log(vidData); directBtn.addEventListener('click', () => window.open(vidData.fallback_url)); directBtn.disabled = false; directBtn.style.background = defaultStyles.background; directBtn.style.cursor = defaultStyles.cursor; }) .catch(err => console.log(err) && null); } addLinks(); if(!window.redditWatcher) { (new MutationObserver(addLinks)).observe(document.body, {childList:true, subtree:true}); } else { window.redditWatcher.body.onUpdate(addLinks); } })();
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址