Skip to content

Instantly share code, notes, and snippets.

@gkostov gkostov/fixSlackTheme.sh
Last active Jul 23, 2019

Embed
What would you like to do?
fixSlackTheme.sh for Slack 4 on OSX
# !!!! make sure asar is available !!!
# npm install -g asar
# remove these to start afresh
rm -rf /Applications/Slack.app/Contents/Resources/app
rm -rf /Applications/Slack.app/Contents/Resources/app.asar.bak.unpacked
mv /Applications/Slack.app/Contents/Resources/app.asar /Applications/Slack.app/Contents/Resources/app.asar.bak 2>/dev/null
# asar needs the .unpacked dir to extract properly and we can just copy this one
cp -r /Applications/Slack.app/Contents/Resources/app.asar.unpacked /Applications/Slack.app/Contents/Resources/app.asar.bak.unpacked
echo "extracting Slack's app.asar";
asar extract /Applications/Slack.app/Contents/Resources/app.asar.bak /Applications/Slack.app/Contents/Resources/app
echo "appending theme code to /Applications/Slack.app/Contents/Resources/app/dist/ssb-interop.bundle.js";
cat << 'EOF' >> /Applications/Slack.app/Contents/Resources/app/dist/ssb-interop.bundle.js
document.addEventListener('DOMContentLoaded', function() {
const cssURI = 'https://gist.githubusercontent.com/gkostov/039fe18fac0c27a4350b274f83403dcb/raw/slack-dark-theme.css',
codeMirrorThemURI = 'https://gist.githubusercontent.com/pdsullivan/32bad68541ccb66ae6d4948f7c9e88bb/raw/f22e0f5de5ff25d$
Promise.all([cssURI, codeMirrorThemURI].map((file)=>{
return fetch(file)
.then( response => {
return response.text();
});
})).then(files => {
files[1] = files[1].replace(/cm-s-cobalt/g, 'cm-s-default');
let styleEl = document.createElement('style');
styleEl.appendChild(document.createTextNode(files.join('\n')));
document.getElementsByTagName('head')[0].appendChild(styleEl);
});
});
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.