-
Notifications
You must be signed in to change notification settings - Fork 0
/
saint2su.js
53 lines (46 loc) · 1.72 KB
/
saint2su.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
// ==UserScript==
// @name saint2.su Download Video Button
// @namespace http://tampermonkey.net/
// @version 1.0
// @description Adds a download button for videos on saint2.su
// @author x
// @match https://saint2.su/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
// Function to create the download button
function createDownloadButton(videoUrl) {
const button = document.createElement('button');
button.innerText = 'Download Video';
button.style.position = 'fixed';
button.style.top = '10px';
button.style.right = '10px';
button.style.zIndex = '1000';
button.style.padding = '10px';
button.style.backgroundColor = '#007BFF';
button.style.color = '#fff';
button.style.border = 'none';
button.style.borderRadius = '5px';
button.style.cursor = 'pointer';
// Add click event to download the video
button.addEventListener('click', function() {
const link = document.createElement('a');
link.href = videoUrl;
link.download = 'video.mp4';
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
});
document.body.appendChild(button);
}
// Function to search for the video source tag and create the download button
function addDownloadButton() {
const videoElement = document.querySelector('source[type="video/mp4"]');
if (videoElement && videoElement.src) {
createDownloadButton(videoElement.src);
}
}
// Run the function after the page has loaded
window.addEventListener('load', addDownloadButton);
})();