Skip to content

Instantly share code, notes, and snippets.

@ctian1
Forked from xmiao2/piazza_top_contrib.js
Created July 7, 2021 21:37
Show Gist options
  • Save ctian1/eee4c0fc5baf669a1a79b11de7a49ece to your computer and use it in GitHub Desktop.
Save ctian1/eee4c0fc5baf669a1a79b11de7a49ece to your computer and use it in GitHub Desktop.
Get the top contributor on piazza class
var delay = 500;
var regex = /\?cid=(\d+)/;
var results = {};
$(".instructor_endorsed_sr").each(function(i, o) {
var iid = setTimeout(function(){
o.click();
// On threads with multiple answers, only first person gets credit?
var name = $("#s_answer .post_region_actions .user_name").first().text() || "Anonymous";
var cid = regex.exec(window.location.search)[1];
console.log(name + ", " + cid);
results[name] = results[name] ? (results[name]+1) : 1;
window.clearTimeout(iid);
}, i*delay);
});
console.log(results);
// var sortable = [];
// for(var name in results) {
// sortable.push([name, results[name]]);
// }
// sortable.sort(function(a,b){return b[1]-a[1]});
// console.log(sortable);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment