Skip to content

Instantly share code, notes, and snippets.

@squatto
Last active September 25, 2018 20:06
Show Gist options
  • Save squatto/286ebe6117d1ece145e798275e651976 to your computer and use it in GitHub Desktop.
Save squatto/286ebe6117d1ece145e798275e651976 to your computer and use it in GitHub Desktop.
Add code to Slack to make it use a dark theme, then kill and re-open Slack. Only adds the code if it isn't there already.
#!/bin/bash
# make Slack use a dark theme css next time it loads
SCRIPT="
//DARKSLACK
document.addEventListener('DOMContentLoaded', function() {
\$.ajax({
url: 'https://cdn.rawgit.com/laCour/slack-night-mode/master/css/raw/black.css',
success: function(css) {
\$('<style></style>').appendTo('head').html(css);
}
});
});
"
FILE=/Applications/Slack.app/Contents/Resources/app.asar.unpacked/src/static/ssb-interop.js
# append the script if it isn't already there
if grep -qF -- "//DARKSLACK" $FILE; then
echo "Slack is already dark, silly"
else
echo "Hello darkness my old friend..."
# append the script (pipe to grep to suppress the echo to stdout)
echo "$SCRIPT" | sudo tee -a $FILE | grep -q fdklsajf
# kill and run Slack
sudo killall Slack
open /Applications/Slack.app
fi
@squatto
Copy link
Author

squatto commented Sep 25, 2018

touch /usr/local/bin/dark-slack
chmod 755 /usr/local/bin/dark-slack

Then just run dark-slack whenever Slack updates 👍

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