Skip to content

Instantly share code, notes, and snippets.

@Bobronium
Last active February 13, 2025 14:37
Show Gist options
  • Save Bobronium/f2a062891c7f663bdabacbfbd9d8eda0 to your computer and use it in GitHub Desktop.
Save Bobronium/f2a062891c7f663bdabacbfbd9d8eda0 to your computer and use it in GitHub Desktop.
Fix Yale Lectures Download URLs
// Use via https://tampermonkey.net/ or https://apps.apple.com/app/userscripts/id1463298887
// ==UserScript==
// @name Fix Yale Lecture Download URLs
// @namespace http://tampermonkey.net/
// @version 1.2
// @description Automatically replace OpenMedia Yale URLs
// @author You
// @match *://*.yale.edu/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
// Helper function to replace the URLs
function replaceUrls() {
const links = document.querySelectorAll('a');
links.forEach(link => {
if (link.href.includes("http://openmedia.yale.edu/cgi-bin/open_yale/media_downloader.cgi?file=")) {
console.log(`Found link to replace: ${link.href}`);
link.href = link.href.replace(
"http://openmedia.yale.edu/cgi-bin/open_yale/media_downloader.cgi?file=",
"http://openmedia.yale.edu/projects"
);
console.log(`Updated link to: ${link.href}`);
}
});
}
// Run once when the DOM is ready
document.addEventListener('DOMContentLoaded', () => {
console.log("DOMContentLoaded: Starting URL replacement...");
replaceUrls();
});
// Observe changes in the DOM to handle dynamically-added content
const observer = new MutationObserver((mutations) => {
console.log("MutationObserver detected changes...");
replaceUrls();
});
// Start observing the document body for changes
observer.observe(document.body, { childList: true, subtree: true });
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment