Skip to content

Instantly share code, notes, and snippets.

@bdaley
Last active December 17, 2018 19:18
Show Gist options
  • Save bdaley/b0c1a3c36111b4e620c71981ebb83b7b to your computer and use it in GitHub Desktop.
Save bdaley/b0c1a3c36111b4e620c71981ebb83b7b to your computer and use it in GitHub Desktop.
Makes student assignment links clickable in Blackboard
// ==UserScript==
// @name URL Maker for Blackboard
// @namespace https://lms.uconn.edu/webapps/assignment/
// @version 0.2
// @description Makes links clickable
// @author Brian Daley <brian@uconn.edu>
// @match https://lms.uconn.edu/webapps/assignment/*
// @grant none
// @downloadUrl https://gist.github.com/bdaley/b0c1a3c36111b4e620c71981ebb83b7b/raw/url-maker-for-blackboard.user.js
// @updateUrl https://gist.github.com/bdaley/b0c1a3c36111b4e620c71981ebb83b7b/raw/url-maker-for-blackboard.user.js
// ==/UserScript==
(function() {
'use strict';
// Regular expression for finding URLs
let re = /\b(https?|ftp|file):\/\/[\-A-Za-z0-9+&@#\/%?=~_|!:,.;]*[\-A-Za-z0-9+&@#\/%=~_|]/ig;
// These are the selectors in Blackboard/HuskyCT that might contain links
let selectors = "#submissionTextView .vtbegenerated p, #currentAttempt_studentComments .vtbegenerated";
// Convert text links to <a> elements
document.querySelectorAll(selectors).forEach((el) => {
el.innerHTML = el.innerHTML.trim().replace(re, function(url){
return `<a href="${url}">${url}</a>`;
});
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment