Skip to content

Instantly share code, notes, and snippets.

@aripalo
Last active August 29, 2015 14:17
Show Gist options
  • Save aripalo/b943aac3b34afa84c29b to your computer and use it in GitHub Desktop.
Save aripalo/b943aac3b34afa84c29b to your computer and use it in GitHub Desktop.
Yammer: get email addresses of group members
/*
* Get email addresses of Yammer group members
* -------------------------------------------
*
* This script works only when everyone in your organization
* has an email of type <FIRSTNAME>.<LASTNAME>@<YOUR-ORGANIZATION-DOMAIN>
* AND
* everyone in your Yammer organization uses real names
* (and therefore have username of type <FIRSTNAME><LASTNAME>)
*
* 1. Go to Yammer Group
* 2. Open Group members modal window
* 3. Edit your organization name and domain for emails in this script
* 4. Run this script in (Chrome/Firefox etc) DevTools
*
*/
// Edit these:
var organizationName = '<YOUR-YAMMER-ORGANIZATION-NAME-HERE>';
var emailDomain = '<DOMAIN-USED-FOR-EMAILS>';
// Works because Yammer has jQuery in it
$('.username a').each(function(){
var userLink = $(this).attr('href');
var userName = userLink.substring(String('https://www.yammer.com/'+organizationName+'/users/').length, userLink.length);
var firstName = this.text.substring(0, this.text.indexOf(' '));
var lastName = this.text.substring(this.text.indexOf(' ')+1, this.text.length);
var slugifiedFirstName = userName.substring(0, firstName.length);
var slugifiedLastName = userName.substring(firstName.length, userName.length);
console.log(slugifiedFirstName+'.'+slugifiedLastName+'@'+emailDomain);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment