Last active
December 17, 2018 19:18
-
-
Save bdaley/b0c1a3c36111b4e620c71981ebb83b7b to your computer and use it in GitHub Desktop.
Makes student assignment links clickable in Blackboard
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 URL Maker for Blackboard | |
// @namespace https://lms.uconn.edu/webapps/assignment/ | |
// @version 0.2 | |
// @description Makes links clickable | |
// @author Brian Daley <[email protected]> | |
// @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