Skip to content

Instantly share code, notes, and snippets.

@Bobronium
Created December 15, 2024 06:19
Show Gist options
  • Save Bobronium/e12ad0e5872ae864b24dea78c5ba6bf0 to your computer and use it in GitHub Desktop.
Save Bobronium/e12ad0e5872ae864b24dea78c5ba6bf0 to your computer and use it in GitHub Desktop.
Fixes download links on Yale. Works with Tampermonkey or Userscripts. The script was written by ChatGPT. The hardest part was to figure out what correct url should look like.
// ==UserScript==
// @name Replace OpenMedia Yale 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';
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=")) {
link.href = link.href.replace(
"http://openmedia.yale.edu/cgi-bin/open_yale/media_downloader.cgi?file=",
"http://openmedia.yale.edu/projects"
);
}
});
}
document.addEventListener('DOMContentLoaded', () => {
replaceUrls();
});
const observer = new MutationObserver((mutations) => {
replaceUrls();
});
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