Skip to content

Instantly share code, notes, and snippets.

@flaki
Last active January 8, 2016 11:17
Show Gist options
  • Save flaki/ac9cc6aae2d3232b6055 to your computer and use it in GitHub Desktop.
Save flaki/ac9cc6aae2d3232b6055 to your computer and use it in GitHub Desktop.
Check Rep status (active/former) in reps.mozilla.org dashboard
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",
'&nbsp;<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