Skip to content

Instantly share code, notes, and snippets.

@jaredmichaelwilliams
Created May 22, 2018 18:20
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 jaredmichaelwilliams/1712e7ae9e39cb72ae48094b8bcff865 to your computer and use it in GitHub Desktop.
Save jaredmichaelwilliams/1712e7ae9e39cb72ae48094b8bcff865 to your computer and use it in GitHub Desktop.
Javscript to invite all slack users to a channel.
1. Open slack in a browser
2. Go to the channel you want to invite everyone to
3. Using Command/Control and the '-' key, make the page small
4. Open the Javascript console
5. Copy into the console the contents of inviteusers.js
6. Hit enter and watch it invite the users.
7. You might have to run it a few times if you have a lot of users and it doesnt add everyone at first
8. Took 4 times to invite 3,000 people to a channel on my slack
var foundAny=false;
function selectAllByLetter(remainingLetters) {
console.log(remainingLetters)
var letter = remainingLetters.pop();
$("#channel_invite_filter").val(letter).trigger("input");
setTimeout(function() {
$(".channel_invite_member:not(hidden)").each(function(i, obj) {
foundAny=true;
this.click();
});
if (remainingLetters.length) {
selectAllByLetter(remainingLetters);
} else {
setTimeout(function() {
console.log("Inviting them all!")
$('.invite_go').click()
},400)
}
},300);
}
function inviteAllUsers() {
foundAny=false;
setTimeout(function () {
setTimeout(function() {
$('#channel_actions_toggle').click();
},100)
setTimeout(function() {
$('#channel_invite_item').click();
},200)
//Enter each letter to trigger searches
var remainingLetters = ["a","b","c","d","e","f","g","h","i","j","v","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"];
selectAllByLetter(remainingLetters);
if (foundAny) {
inviteAllUsers();
}
}, 4000);
}
inviteAllUsers();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment