This repository has been archived by the owner on Oct 7, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ZoomSave.user.js
63 lines (55 loc) · 2.66 KB
/
ZoomSave.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
61
62
63
// ==UserScript==
// @name Zoom™ Save 3
// @namespace https://mrbhanukab.github.io/ZoomSave/
// @version 3.0
// @description Download Zoom™ Recordings Quickly 🔥
// @author Bhanuka Bandara
// @homepage https://mrbhanukab.github.io
// @icon https://github.com/mrbhanukab/ZoomSave/blob/main/assets/logo512.png?raw=true
// @supportURL https://github.com/mrbhanukab/ZoomSave
// @match https://*.zoom.us/rec*
// @grant none
// ==/UserScript==
(function() {
'use strict';
// Check if the current URL has "component-page" after "/rec/" and exit if it does
if (/\/rec\/component-page/.test(window.location.href)) {
return;
}
console.log("Zoom™ Save userscript is running!");
function modifyPage() {
let spanElement = document.querySelector('h1[data-v-f8df28cc][data-v-c5781866].r-title span[data-v-f8df28cc].extra');
let videoElement = document.getElementById('vjs_video_3_html5_api');
let fileNameSpan = document.querySelector('h1[data-v-f8df28cc][data-v-c5781866].r-title span[data-v-f8df28cc].topic');
let fileName = fileNameSpan ? fileNameSpan.textContent.trim().replace(/ /g, '_') + '.mp4' : "download.mp4";
if (spanElement && videoElement) {
let src = videoElement.getAttribute('src');
if (src) {
// Create an anchor (link)
let a = document.createElement('a');
a.href = src;
a.download = fileName; // Sets the download filename
a.textContent = "(Click Here To Download)";
a.style.cursor = "pointer";
a.style.textDecoration = "underline";
a.style.color = "blue";
a.style.marginLeft = "10px"; // Add 10 pixels of space to the left of the link
// Replace the span with the anchor element
spanElement.parentNode.replaceChild(a, spanElement);
return true; // Return true if modification is successful
} else {
alert("Zoom™ Save Error: Video URL not found!");
}
} else {
console.log("Zoom™ Save userscript couldn't find the required elements!");
alert("Zoom™ Save Error: Required elements not found on the page!");
}
return false; // Return false if elements not found or modification unsuccessful
}
// Set a periodic check every 2 seconds (2000 milliseconds)
let checkInterval = setInterval(function() {
if (modifyPage()) {
clearInterval(checkInterval); // Stop the interval once we've successfully modified the page
}
}, 2000);
})();