Created
February 25, 2026 16:59
-
-
Save daxmc99/32df1bd5a3e5dabf49f36a6c2446bb1a to your computer and use it in GitHub Desktop.
Rename Gatech mediaspace transcripts to the video title
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 Gatech Mediaspace: transcript named after video | |
| // @version 1.1 | |
| // @match https://mediaspace.gatech.edu/media/* | |
| // @grant GM_download | |
| // @connect www.kaltura.com | |
| // @connect cdnapisec.kaltura.com | |
| // @run-at document-end | |
| // ==/UserScript== | |
| (() => { | |
| "use strict"; | |
| /* ========================= | |
| DEBUG SECTION (disabled) | |
| Uncomment to enable logging | |
| ========================== */ | |
| /* | |
| const DEBUG = true; | |
| const dlog = (...a) => console.log("[txdbg]", ...a); | |
| if (DEBUG) { | |
| dlog("script loaded", location.href); | |
| const links = document.querySelectorAll( | |
| 'a.kms-ds-media-page-moduledata-attachment[href*="kaltura.com/api_v3/service/attachment_attachmentasset/action/serve/"]' | |
| ); | |
| dlog("found transcript links", [...links].map(a => ({ | |
| href: a.href, | |
| download: a.getAttribute("download") | |
| }))); | |
| } | |
| */ | |
| const transcriptSel = | |
| 'a.kms-ds-media-page-moduledata-attachment[href*="kaltura.com/api_v3/service/attachment_attachmentasset/action/serve/"]'; | |
| const sanitize = (s) => | |
| s.replace(/[\/\\:*?"<>|]+/g, "_") | |
| .replace(/\s+/g, " ") | |
| .trim() | |
| .slice(0, 180); | |
| const getTitle = () => { | |
| const h = document.querySelector('h3.MuiTypography-h3, h3[class*="MuiTypography-h3"], h1'); | |
| const t = (h?.textContent?.trim() || document.title.trim()); | |
| return sanitize(t); | |
| }; | |
| const isJson = (a) => | |
| (a.getAttribute("download") || "").toLowerCase().endsWith(".json"); | |
| document.addEventListener( | |
| "click", | |
| (e) => { | |
| const a = e.target.closest(transcriptSel); | |
| if (!a) return; | |
| if (isJson(a)) return; | |
| e.preventDefault(); | |
| e.stopPropagation(); | |
| const filename = `${getTitle()}.txt`; | |
| /* DEBUG download logging | |
| dlog("intercepted click", { | |
| href: a.href, | |
| originalDownloadAttr: a.getAttribute("download"), | |
| newName: filename | |
| }); | |
| */ | |
| GM_download({ | |
| url: a.href, | |
| name: filename, | |
| saveAs: true, | |
| headers: { Referer: location.href }, | |
| /* DEBUG callbacks | |
| onload: () => dlog("GM_download onload"), | |
| onerror: (err) => dlog("GM_download onerror", err), | |
| ontimeout: () => dlog("GM_download ontimeout"), | |
| */ | |
| }); | |
| }, | |
| true | |
| ); | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment