Last active
January 8, 2016 11:17
-
-
Save flaki/ac9cc6aae2d3232b6055 to your computer and use it in GitHub Desktop.
Check Rep status (active/former) in reps.mozilla.org dashboard
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
if (window.location.toString() === "https://reps.mozilla.org/dashboard/") { | |
[].forEach.call( | |
document.querySelectorAll('#dashboard-mentorship-block [href*="/u/"]'), | |
function(a) { | |
console.log("Checking "+a.href+" ... "); | |
var r = new XMLHttpRequest(); | |
r.open("GET", a.href); | |
r.onreadystatechange = function () { | |
if (r.readyState != 4 || r.status != 200) return; | |
var former = r.responseText.match(/Former Rep/); | |
if (former) console.log(a.textContent.trim() + " is a former rep"); | |
a.insertAdjacentHTML("afterend", | |
' <span style="border-radius:4px;background:'+(former?'gray':'green')+';color:white;padding:2px;font-size:9px;">' | |
+(former?'former':'active') | |
+'</span>' | |
); | |
}; | |
r.send(); | |
}); | |
} else { | |
alert("Run this in your Reps dashboard after logging in! ;)"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment