Last active
October 7, 2025 13:59
-
-
Save lart2150/f876f59f57bf4fd460120e597813b66b to your computer and use it in GitHub Desktop.
Get direct links to hihest quality reddit video. Does not include audio.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ==UserScript== | |
| // @name Reddit Video direct links links | |
| // @namespace https://lart2150.com/ | |
| // @version 0.4 | |
| // @description Get direct links to reddit videos. | |
| // @author /u/lart2150 | |
| // @match https://www.reddit.com/* | |
| // @icon https://www.google.com/s2/favicons?sz=64&domain=reddit.com | |
| // @grant none | |
| // ==/UserScript== | |
| const getRedditDirectLinks = async () => { | |
| 'use strict'; | |
| const videos = Array.from(document.getElementsByTagName('shreddit-player')).filter( | |
| (v) => { | |
| //v.directLink!== true && && v.childNodes.length === 1 | |
| return v.directLink!== true | |
| } | |
| ); | |
| console.info(`getting direct links for ${videos.length} videos`); | |
| for (const video of videos) { | |
| try { | |
| video.directLink = true; | |
| const url = video.src.split('?')[0]; | |
| if (!url.toString().match(/preview\.redd\.it\/.*format=mp4/) && | |
| !url.toString().match(/v\.redd\.it\/.*\/HLSPlaylist.m3u8/)) { | |
| console.log('skipping ', video); | |
| continue; | |
| } | |
| const lnk = document.createElement('a'); | |
| const linkText = document.createTextNode(url); | |
| lnk.appendChild(linkText); | |
| const linkUrl = new URL('https://www.hlsplayer.org/play'); | |
| linkUrl.searchParams.set('url', url); | |
| lnk.href = linkUrl.toString(); | |
| lnk.target = '_blank'; | |
| video.parentElement.parentElement.parentElement.parentElement.parentElement.appendChild(lnk); | |
| } catch (e) { | |
| console.log('error getting video direct link', e, video); | |
| } | |
| } | |
| setTimeout(getRedditDirectLinks, 5000);//wait 5 seconds to run again | |
| }; | |
| setTimeout(getRedditDirectLinks, 1000);//wait 1 second for first run |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment