Skip to content

Instantly share code, notes, and snippets.

@summersab
Last active December 26, 2019 17:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save summersab/cb7355f27d702b07a2751fc43c872610 to your computer and use it in GitHub Desktop.
Save summersab/cb7355f27d702b07a2751fc43c872610 to your computer and use it in GitHub Desktop.
Quickly find emails for a GitHub user
javascript:(function()%7B%2F%2FTurn this into a bookmarklet using a tool like https%3A%2F%2Fwww.shareprogress.org%2Fbookmarklet%2F%0Aemails %3D %5B%5D%3B%0Axhr %3D new XMLHttpRequest()%3B%0A%0Axhr.onload %3D () %3D> %7B%0A%09if (xhr.status %3D%3D 200) %7B%0A%09%09var result %3D JSON.parse(xhr.response)%3B%0A%09%09result.forEach(function(obj) %7B%0A%09%09%09if (obj.type %3D%3D %27PushEvent%27) %7B%0A%09%09%09%09email %3D obj.payload.commits%5B0%5D.author.email%3B%0A%09%09%09%09if (email.includes(%27noreply%27) %7C%7C email.includes(%27no-reply%27)) %7B%0A%09%09%09%09%09%2F%2FI know there%27s a better way to do this%2C but I%27m too lazy. This works.%0A%09%09%09%09%7D%0A%09%09%09%09else if (!emails.includes(email)) %7B%0A%09%09%09%09%09emails.push(email)%3B%0A%09%09%09%09%7D%0A%09%09%09%7D%0A%09%09%7D)%3B%0A%09%09if (emails.length > 0) %7B%0A%09%09%09output %3D emails.join(%27%2C%27)%3B%0A%09%09%7D%0A%09%09else %7B%0A%09%09%09output %3D "No emails found."%3B%0A%09%09%7D%0A%09%09var textnode %3D document.createTextNode(output)%3B%0A%09%09document.body.insertBefore(textnode%2C document.body.firstChild)%3B%0A%09%7D else %7B%0A%09%09var textnode %3D document.createTextNode(%27Error%27)%3B%0A%09%09document.body.insertBefore(textnode%2C document.body.firstChild)%3B%0A%09%7D%0A%7D%3B%0A%0Ausername %3D window.location.href.split(%27%2F%27)%5B3%5D%3B%0A%0Axhr.open(%27GET%27%2C %27https%3A%2F%2Fapi.github.com%2Fusers%2F%27 %2B username %2B %27%2Fevents%2Fpublic%27)%3B%0Axhr.send()%3B%7D)()
//Turn this into a bookmarklet using a tool like https://www.shareprogress.org/bookmarklet/
emails = [];
xhr = new XMLHttpRequest();
xhr.onload = () => {
if (xhr.status == 200) {
var result = JSON.parse(xhr.response);
result.forEach(function(obj) {
if (obj.type == 'PushEvent') {
email = obj.payload.commits[0].author.email;
if (email.includes('noreply') || email.includes('no-reply')) {
//I know there's a better way to do this, but I'm too lazy. This works.
}
else if (!emails.includes(email)) {
emails.push(email);
}
}
});
if (emails.length > 0) {
output = emails.join(',');
}
else {
output = "No emails found.";
}
var textnode = document.createTextNode(output);
document.body.insertBefore(textnode, document.body.firstChild);
} else {
var textnode = document.createTextNode('Error');
document.body.insertBefore(textnode, document.body.firstChild);
}
};
username = window.location.href.split('/')[3];
xhr.open('GET', 'https://api.github.com/users/' + username + '/events/public');
xhr.send();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment