Skip to content

Instantly share code, notes, and snippets.

@Akii
Last active June 24, 2019 07:55
Show Gist options
  • Save Akii/3b916b6a7f9147e9cb364883be31a369 to your computer and use it in GitHub Desktop.
Save Akii/3b916b6a7f9147e9cb364883be31a369 to your computer and use it in GitHub Desktop.
Basically a starting point of hiding channels and blocking users in Slack
document.addEventListener("DOMContentLoaded", function() {
let hiddenChannels = ['general']
let blockedUsers = ['Slackbot']
let customCss = `
.p-channel_sidebar__static_list div[role="listitem"]:empty { display: none; }
`
hiddenChannels.concat(blockedUsers).forEach(it => {
customCss += `a[aria-label~="${it}"] { display: none; }\n`
})
let s = document.createElement('style');
s.type = 'text/css';
s.innerHTML = customCss;
document.head.appendChild(s);
let remover = function () {
setTimeout(function () {
hiddenChannels.forEach(it => {
document.querySelectorAll(`a[aria-label~="${it}"]`).forEach(it => it.remove());
})
blockedUsers.forEach(it => {
document.querySelectorAll(`a[aria-label~="${it}"]`).forEach(it => it.parentNode.remove());
})
remover();
}, 250);
}
remover();
});
@Akii
Copy link
Author

Akii commented Jun 24, 2019

Yes, I know. You might think: if you need this, something is wrong with your organisation. And maybe that's true. I just don't care and want more control about what I'm exposing myself to on Slack.

How to install:
Append Gist contents to this file: /Applications/Slack.app/Contents/Resources/app.asar.unpacked/src/static/ssb-interop.js

How it works:
It just adds some CSS and removes DOM elements. That means, you have to mute the channel you want to hide (usually, that's general). Regarding users: It will not hide notifications correctly. Not sure what to do about that yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment