UPDATE: As of Slack 4.0, the methods below no longer work. I've had success using this: https://github.com/LanikSJ/slack-dark-mode
I recently got this from a co-worker and thought I would share. If you want a quick and easy way of implementing a dark theme in Slack, do the following:
On a Mac, navigate to this directory:
cd /Applications/Slack.app/Contents/Resources/app.asar.unpacked/src/static
Edit the file ssb-interop.js
with a text editor.
Add this code to the very bottom (*edited thanks to amerritt14 for code support):
document.addEventListener('DOMContentLoaded', function() {
$.ajax({
url: 'https://cdn.jsdelivr.net/gh/laCour/slack-night-mode/css/raw/black.css',
success: function(css) {
let overrides = `
code { background-color: #535353; color: #85c5ff; } /* Change color: to whatever font color you want */
.c-mrkdwn__pre, .c-mrkdwn__quote { background: #535353 !important; background-color: #535353 !important; }
`
$("<style></style>").appendTo('head').html(css + overrides);
}
});
});
Save the file and restart Slack, you should have a Dark theme!
Top comments (44)
code one-liner for repeated injection:
just paste in terminal and hit enter
sudo tee -a fix from sven
i have modified Fynn’s one liner to allow the script to be executed multiple times without adding the code more than once. If you place this script in an automator application on your mac, you can add it as a startup program so that it runs on boot.
edit: Implemented Wayne's jsdelivr modification, used absolute path to ssb-interop.js in sed command
I love this community
For the security conscious among us (or those on corporate networks that would kill us for including external code in a JS File in our slack), here's a version that inlines the contents of that file, and asks you for permission before updating so you can check out the "css" downloaded.
(I put "css" in quotes because there's a risk that the code could be compromised and not be CSS at all. Articles like this hackernoon.com/im-harvesting-credi... make me nervous about these types of attack vectors).
In any case:
Hey fynn, I tried this command and got the following error:
-bash: /Applications/Slack.app/Contents/Resources/app.asar.unpacked/src/static/ssb-interop.js: Permission denied
Any idea why?
well, sounds like you don't have the right permissions to edit that file.
just add
sudo
at the beginning of the one-liner (on a ctrl + a
gets you there).Should have said this in my original post, but
sudo
doesn't seem to help. I have admin permissions on this computer, though it's running Mojave and I'm not sure if that added any complications. I also dragged Terminal into "Full Disk Access" in Security & Privacy preferences just to be sure. Weird.well, admin permissions and sudo aren't really the same. some files have an extra layer of "protection".
what does
ls -la /Applications/Slack.app/Contents/Resources/app.asar.unpacked/src/static/ssb-interop.js
say?Here's what I get:
-rw-r--r-- 1 root wheel 3806 Oct 22 09:03 /Applications/Slack.app/Contents/Resources/app.asar.unpacked/src/static/ssb-interop.js
(I edited the file manually this morning to get it working)
yeah so the file belongs to the
root
user.. not you, meaning you have to usesudo
orchown
Just use
to fix your permission issues.
This post inspired this CLI tool, which make it easy to switch among 8 available themes with simple commands like
to use dark mode, or
to revert to light mode.
Right now, my slack automatically changes to dark mode at dusk and returns during the day 😄
This is awesome! Thanks!
Amazing!
Hey!
How do you automatically change to dark mode at dusk and returns during the day?
With Automator?
Thanks,
Noah
They have scripts out there. Checkout medium.com/the-andela-way/automati... and stackoverflow.com/questions/493349....
This awesome dark theme stopped working in Slack 4.0.0. The filepath is broken. Path
/Applications/Slack.app/Contents/Resources/app.asar.unpacked/src/static/ssb-interop.js
no longer works because .../src folder has been entirely deleted. I guess Slack introduced a new place for the ssb-interop.js file or replaced it with new implementation.
Any solutions from anyone?
This worked for me: github.com/LanikSJ/slack-dark-mode
I still looking at how to solve this...
This will work for you. Again, put it at the end of the ssb-interop.js file. If you are running on Windows, use the forward slash and start the path with 'C:/' :
document.addEventListener('DOMContentLoaded', function() {
var fs = require('fs'),
filePath = '/Applications/Slack.app/Contents/Resources/black-slack.css';
fs.readFile(filePath, {encoding: 'utf-8'}, function(err, data) {
if (!err) {
var css = document.createElement('style')
css.innerText = data;
document.getElementsByTagName('head')[0].appendChild(css);
}
})
});
Some of the markup needs to be fixed.
'code' '''preformatted''' and >quote are all black on black backgrounds and you can't see them. I edited the above code to include:
Edited: fixed a typo in the code snippit.
Edited: found a way to also fix backgrounds for '''preformatted''' and >quote
rawgit.com
is shutting down. Probably best to use jsdelivr now:https://cdn.jsdelivr.net/gh/laCour/slack-night-mode/css/raw/black.css
I don't need any overrides anymore because the issues I was having have been fixed in master.
At the bottom of ssb-interob.js:
Hello,
It looks like 3.3.8 broke the skin in the slack "Thread" part
Can someone advise me on how to fix this.
This skin is ery important to me because we are running shift rotations.
Thank you in advance.
Bart
On Windows, you can use this in Explorer to navigate to the correct file
%localappdata%\slack\
You're the hero our office needed today for this. Where can I send a case of ramen?
Hello
I am using 4.0.0 64-bit version on Windows and the suggested directory does no longer exist. We have now :
\AppData\Local\slack\app-4.0.0\resources\app.asar.unpacked:
+---dist
+---node_modules