Skip to content

Instantly share code, notes, and snippets.

@ssoroka
Last active July 24, 2019 18:42
Show Gist options
  • Save ssoroka/2e9bc1f1a0ab876cf201a124333cdbe8 to your computer and use it in GitHub Desktop.
Save ssoroka/2e9bc1f1a0ab876cf201a124333cdbe8 to your computer and use it in GitHub Desktop.
upgrade to dark slack.
// First make sure the wrapper app is loaded
document.addEventListener("DOMContentLoaded", function() {
// Then get its webviews
let webviews = document.querySelectorAll(".TeamView webview");
// Fetch our CSS in parallel ahead of time
const cssPath = 'https://raw.githubusercontent.com/Nockiro/slack-black-theme/master/custom.css';
let cssPromise = fetch(cssPath).then(response => response.text());
let customCustomCSS = `
:root {
/* Modify these to change your theme colors: */
--primary: #61AFEF;
--text: #ABB2BF;
--background: #282C34;
--background-elevated: #3B4048;
}
a[aria-label^="NAME_OF_CHANNEL_OR_DIRECT_CONVO_TO_STYLE"]
{
--background: #4d0000 !important;
--text-transform: uppercase !important;
--letter-spacing: 2px !important;
--text-shadow: 1px 1px white;
} `
// Insert a style tag into the wrapper view
cssPromise.then(css => {
let s = document.createElement('style');
s.type = 'text/css';
s.innerHTML = css + customCustomCSS;
document.head.appendChild(s);
});
// Wait for each webview to load
webviews.forEach(webview => {
webview.addEventListener('ipc-message', message => {
if (message.channel == 'didFinishLoading')
// Finally add the CSS into the webview
cssPromise.then(css => {
let script = `
let s = document.createElement('style');
s.type = 'text/css';
s.id = 'slack-custom-css';
s.innerHTML = \`${css + customCustomCSS}\`;
document.head.appendChild(s);
`
webview.executeJavaScript(script);
})
});
});
});
# install:
# curl https://gist.githubusercontent.com/ssoroka/2e9bc1f1a0ab876cf201a124333cdbe8/raw/install.sh | sudo sh
set -ex
cd /Applications/Slack.app/Contents/Resources/app.asar.unpacked/src/static
curl https://gist.githubusercontent.com/ssoroka/2e9bc1f1a0ab876cf201a124333cdbe8/raw/extension.js > extension.js
cat extension.js >> index.js
cat extension.js >> ssb-interop.js
echo Done! Please restart slack.
@ssoroka
Copy link
Author

ssoroka commented Jul 24, 2019

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