Skip to content

Instantly share code, notes, and snippets.

@Ynng
Created January 7, 2022 05:36
Show Gist options
  • Save Ynng/48b581b1f23c614361ce072ec8d204d5 to your computer and use it in GitHub Desktop.
Save Ynng/48b581b1f23c614361ce072ec8d204d5 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Waterloo Learn URL Extractor
// @namespace Waterloo Learn URL Extractor
// @version 0.1
// @description Hate it when you book mark a section in the "content" tab in waterloo learn, but the bookmark just doesn't work? This script puts the full url into each link, so when your bookmark has the full url too.
// @author Ynng
// @match https://learn.uwaterloo.ca/d2l/le/content/*
// @icon https://www.google.com/s2/favicons?domain=uwaterloo.ca
// @grant none
// ==/UserScript==
(function () {
'use strict';
let content_tree = document.getElementById("D2L_LE_Content_TreeBrowser");
let children = Array.from(content_tree.children);
children.forEach(li => {
let itemChildren = Array.from(li.children);
let target = itemChildren[0]
if (target.tagName != "A") return;
if (li.getAttribute("data-key")) target.setAttribute("href", window.location.pathname + "?itemIdentifier=" + li.getAttribute("data-key"));
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment