Skip to content

Instantly share code, notes, and snippets.

@jmclemo6
Created January 10, 2018 21:35
Show Gist options
  • Save jmclemo6/1f77bbaad864c465d7565a3f3a0642d1 to your computer and use it in GitHub Desktop.
Save jmclemo6/1f77bbaad864c465d7565a3f3a0642d1 to your computer and use it in GitHub Desktop.
UTK CS Discord Mass Mail Script
// Your browser must support ES6 async / await, Promises, and Template Strings for this to work.
// Do not remove the sleeps to make it faster. They are there to allow time for the Ajax calls that Canvas makes to process.
// If you are on a slow connection, you might need to increase the length of the sleep calls.
// I've also made it up to you to click the send button. Be sure to check that you pasted your invite url correctly.
// To run this:
// * Go to the page on Canvas where you can see your messages from the class you want to send the invite to.
// * Open your browser's console using F12 or by right clicking and then selecting "Inspect Element".
// * Paste the below code into your console window and hit enter.
// * Then enter add_students("INSERT_INVITE_URL_HERE"); into your console window and hit enter.
// * The script will run and then all you have to do is proofread and hit send!
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
async function add_students(discord_invite_url) {
document.getElementById('compose-btn').click();
document.getElementById('compose-message-subject').value = "Join the UTK CS/CE Student Discord Server!"
document.getElementById("recipient-search-btn").click();
await sleep(500);
var clickEvent = document.createEvent('MouseEvents');
clickEvent.initEvent("mousedown", true, true);
document.querySelector('li[aria-label="Students"]').dispatchEvent(clickEvent);
await sleep(500);
var student_list = document.getElementsByClassName("message-header")[0].getElementsByClassName("ac-result-list collectionViewItems")[0].children;
for (var i = 1; i < student_list.length; i++) {
var student_click_event = document.createEvent("MouseEvents");
student_click_event.initEvent("mousedown", true, true);
student_list[i].dispatchEvent(student_click_event);
document.getElementById("recipient-search-btn").click();
await sleep(500);
document.querySelector('li[aria-label="Students"]').dispatchEvent(clickEvent);
await sleep(500);
}
document.getElementById('bulk_message').click();
document.getElementsByClassName('compose_form')[0].getElementsByClassName('message-body')[0].children[0].value = `Go to this URL to join: ${discord_invite_url} \n
WHY YOU SHOULD USE DISCORD INSTEAD!
===================================
* Class Channels! Find groupmates in other CS/CE classes easily!
* Find TAs, get help from upperclass students, and chat about special other topics like Linux and gaming!
* Code highlighting! Color-format and block-paste code in easy-to-read formats!
* Web, desktop, and mobile applications available!
* Gain points and XP for being active and helping your classmates!
* Use custom emojis and react to other messages with up to 20 emotes at once!
* Find students who have already taken the CS classes you're looking for, and get recommendations and personal experience from other members!
* Post your personal CS projects and find other people with similar interests!`;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment