Created
September 15, 2017 21:06
-
-
Save retrography/d7895bb9afa62fef4672342c5c836a82 to your computer and use it in GitHub Desktop.
A bookmarklet that downloads group names and group members in a groupset on Canvas in csv format
This file contains 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
var groups = []; | |
document.querySelectorAll("li.group").forEach( | |
function(group) { | |
name = group.querySelector("span.group-name").textContent; | |
members = []; | |
group.querySelectorAll("div.group-user-name").forEach( | |
function(member) { | |
members.push(member.textContent.trim() + "\t" + name); | |
} | |
); | |
groups.push(members.join("\n")); | |
} | |
); | |
groups = groups.join("\n").trim(); | |
var filename = "groups.tsv"; | |
if (groups.length >= 1) { | |
var blob = new Blob([groups], { | |
type: "text/csv;charset=utf-8;" | |
}); | |
if (window.navigator.msSaveOrOpenBlob) { | |
window.navigator.msSaveBlob(blob, filename); | |
} else { | |
var elem = window.document.createElement('a'); | |
elem.href = window.URL.createObjectURL(blob); | |
elem.download = filename; | |
document.body.appendChild(elem); | |
elem.click(); | |
document.body.removeChild(elem); | |
window.URL.revokeObjectURL(elem.href); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment