-
Notifications
You must be signed in to change notification settings - Fork 44
/
reddit video download button.user.js
60 lines (55 loc) · 2.68 KB
/
reddit video download button.user.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// ==UserScript==
// @name reddit video download button
// @author murrty
// @match http*://*.reddit.com/r/*
// @grant none
// @version 1.1
// @homepage https://github.com/murrty/youtube-dl-gui
// @updateURL https://github.com/murrty/youtube-dl-gui/raw/master/Addons/reddit%20video%20download%20button.user.js
// @downloadURL https://github.com/murrty/youtube-dl-gui/raw/master/Addons/reddit%20video%20download%20button.user.js
// @description Adds a "download video" button to the post. Old reddit only.
// @run-at document-end
// ==/UserScript==
// This only works on old.reddit.com.
// or if the old layout is enabled in the user settings.
var VideoPlayers = document.getElementsByClassName("reddit-video-player-root");
if (VideoPlayers.length > 0) {
var Protocol = "ytdlgui:";
var Url = " \"" + document.URL + "\"";
var TagLines = document.getElementsByClassName("flat-list buttons");
if (TagLines.length > 0 && TagLines[0] != null) {
var VideoDownloadItem = document.createElement('li');
var VideoLink = document.createElement('a');
VideoLink.id = "download-video";
VideoLink.title = "Downloads the video using youtube-dl-gui.";
VideoLink.href = Protocol + "v" + Url;
VideoLink.appendChild(document.createTextNode("download video"));
VideoDownloadItem.append(VideoLink);
var AudioDownloadItem = document.createElement('li');
var AudioLink = document.createElement('a');
AudioLink.id = "download-video-audio";
AudioLink.title = "Downloads the videos audio using youtube-dl-gui.";
AudioLink.href = Protocol + "a" + Url;
AudioLink.appendChild(document.createTextNode("download audio"));
AudioDownloadItem.append(AudioLink);
var CustomDownloadItem = document.createElement('li');
var CustomLink = document.createElement('a');
CustomLink.id = "download-video-custom";
CustomLink.title = "Downloads the video custom arguments using youtube-dl-gui.";
CustomLink.href = Protocol + "c" + Url;
CustomLink.appendChild(document.createTextNode("download custom"));
CustomDownloadItem.append(CustomLink);
TagLines[0].append(VideoDownloadItem);
TagLines[0].append(AudioDownloadItem);
TagLines[0].append(CustomDownloadItem);
}
}
//else {
// var VideoExpandObjects = document.getElementsByClassName("expando-button collapsed video") + document.getElementsByClassName("expando-button video expanded");
// if (VideoExpandObjects.length > 0) {
// console.log(VideoExpandObjects.length + " objects found");
// }
// else {
// console.log("no video objects found");
// }
//}