Last active
April 4, 2020 11:33
-
-
Save green6erry/12b465d2042c8902a2b14a1cc22027b9 to your computer and use it in GitHub Desktop.
Georgia Tech OMSCS Reddit admissions thread console snippet
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
class Post { | |
constructor(postText) {this.postText = postText} | |
get status() { return this.filterValue('status');} | |
get appliedDate() {return this.filterValue('application date');} | |
get decidedDate() {return this.filterValue('decision date');} | |
filterValue(str) { | |
let regEx = new RegExp(str + ':.*', 'gi'); | |
let match = this.postText.match(regEx); | |
let fieldValue = match && match[0].substring(str.length + 1, match[0].length).trim(); | |
return fieldValue; | |
} | |
}; | |
// set up all the counts | |
let totalCount = 0, responsesCount = 0, acceptanceCount = 0, css = "padding-bottom: 1em; text-shadow: -1px -1px hsl(50, 63%, 60%), 1px 1px hsl(50, 63%, 55%), 3px 2px hsl(50, 63%, 50%), 5px 3px hsl(50, 63%, 45%), 7px 4px hsl(50, 63%, 40%), 9px 5px hsl(50, 63%, 35%), 11px 6px hsl(50, 63%, 30%), 13px 7px hsl(50, 63%, 25%), 14px 8px hsl(50, 63%, 20%), 16px 9px hsl(50, 63%, 15%), 18px 10px hsl(50, 63%, 10%), 20px 11px hsl(50, 63%, 5%), 22px 12px hsl(50, 63%, 15%), 23px 13px hsl(50, 63%, 30%), 25px 14px hsl(50, 63%, 45%), 27px 15px hsl(50, 63%, 60%), 28px 16px hsl(50, 63%, 65%), 30px 17px; font-size: 40px;"; | |
// find all the posts on the page | |
let posts = document.querySelectorAll('.entry'); | |
// iterate over each post | |
posts.forEach((post) => { | |
// siphon off the data with regex | |
let p = new Post(post.innerText), {status, appliedDate, decidedDate} = p; | |
// if the post has all the right pieces AND isn't the template, then include it in all post data | |
if (status && appliedDate && decidedDate && status.indexOf("Choose One") < 0) { | |
const responded = (parseInt(decidedDate)), accepted = (status.indexOf('ccepted') > 0); | |
// if the post has a result, include in responses data | |
if (responded || accepted) { | |
console.group(`%cResponse ${++responsesCount}`, 'font-family: Georgia'); | |
console.log(`Status: %c${status}\n%capplied: ${appliedDate}\ndecided: ${decidedDate}`, `color: white; background-color: ${accepted ? '#d4b117' : 'black'}`, 'color: black'); | |
console.groupEnd(); | |
acceptanceCount += accepted ? 1 : 0; | |
} | |
totalCount++; | |
} | |
}); | |
// define percents ahead of time for easier reading | |
let heardBackPercent = Math.floor((responsesCount / totalCount) * 100), acceptancePercent = Math.floor((acceptanceCount / responsesCount) * 100); | |
console.group('%cTotals', 'font-family: Georgia'); | |
console.log("waiting: ", totalCount - responsesCount); | |
console.log("responses: ", responsesCount); | |
console.log(`responses acceptance rate: %c${acceptancePercent}%`, `color: green`); | |
console.log("total entries: ", totalCount); | |
console.log("%c%s", css, `${responsesCount} out of ${totalCount} people have heard back (about ${heardBackPercent}%)`); | |
console.groupEnd(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment