-
Notifications
You must be signed in to change notification settings - Fork 107
/
slack-dark-mode.sh
executable file
·34 lines (27 loc) · 1.27 KB
/
slack-dark-mode.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/env bash
JS="
// First make sure the wrapper app is loaded
document.addEventListener('DOMContentLoaded', function() {
// Fetch our CSS in parallel ahead of time
const cssPath = 'https://raw.githubusercontent.com/caiceA/slack-raw/master/slack-4';
let cssPromise = fetch(cssPath).then((response) => response.text());
// Insert a style tag into the wrapper view
cssPromise.then((css) => {
let s = document.createElement('style');
s.type = 'text/css';
s.innerHTML = css;
document.head.appendChild(s);
});
});"
case "${OSTYPE}" in
linux*) SLACK_RESOURCES_DIR="/usr/lib/slack/resources" ;;
darwin*) SLACK_RESOURCES_DIR="/Applications/Slack.app/Contents/Resources" ;;
*) echo "Unsupported OS: ${OSTYPE}"; exit 1 ;;
esac
SLACK_FILE_PATH="${SLACK_RESOURCES_DIR}/app.asar.unpacked/dist/main-preload-entry-point.bundle.js"
echo "Adding Dark Theme Code to Slack... "
echo "This script requires sudo privileges." && echo "You'll need to provide your password."
sudo npx asar extract ${SLACK_RESOURCES_DIR}/app.asar ${SLACK_RESOURCES_DIR}/app.asar.unpacked
sudo tee -a "${SLACK_FILE_PATH}" > /dev/null <<< "$JS"
sudo npx asar pack ${SLACK_RESOURCES_DIR}/app.asar.unpacked ${SLACK_RESOURCES_DIR}/app.asar
echo "Restart slack to let the changes take effect."