Created
October 8, 2018 13:34
-
-
Save andrewssobral/c86e304701158884d1ddb31ecb0412b1 to your computer and use it in GitHub Desktop.
slack_dark_theme
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// First make sure the wrapper app is loaded | |
// https://github.com/widget-/slack-black-theme/issues/48 | |
// alias slackdark='cat ~/slack_dark_theme.js >> /Applications/Slack.app/Contents/Resources/app.asar.unpacked/src/static/ssb-interop.js' | |
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://cdn.rawgit.com/widget-/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; | |
} | |
div.c-message.c-message--light.c-message--hover, | |
.p-flexpane_header, | |
.p-shortcuts_flexpane__title, | |
.c-message_list__day_divider, | |
.c-message_list__day_divider__label, | |
.c-message_list__day_divider__label__pill, | |
.p-message_pane .c-message_list.c-virtual_list--scrollbar>.c-scrollbar__hider:before, | |
.p-message_pane .c-message_list:not(.c-virtual_list--scrollbar):before, | |
.c-keyboard_key { | |
color: #fff !important; | |
background-color: #222 !important; | |
} | |
span.c-message__body, | |
a.c-message__sender_link, | |
span.c-message_attachment__media_trigger.c-message_attachment__media_trigger--caption, | |
div.p-message_pane__foreword__description span, | |
.c-message_attachment, | |
.p-shortcuts_flexpane__shortcut_title { | |
color: #afafaf !important; | |
} | |
pre.special_formatting { | |
background-color: #222 !important; | |
color: #8f8f8f !important; | |
border: solid; | |
border-width: 1 px !important; | |
} | |
.c-message, | |
.c-virtual_list__item, | |
.c-member_slug--link { | |
background-color: #222 !important; | |
} | |
#client_body:not(.onboarding):not(.feature_global_nav_layout):before { | |
background-color: #222 !important; | |
border: 1px solid #222 !important; | |
box-shadow: none !important; | |
} | |
.ql-placeholder, .c-team__display-name, .c-unified_member__display-name, .c-usergroup__handle, .timezone_value, .timezone, .p-message_pane__foreword__description, .charcoal_grey { | |
color: #ccc !important; | |
} | |
div[role=listitem]:first-child { | |
margin-bottom: 20px !important; | |
} | |
div[role="presentation"]:not(class="c-submenu") { background-color: #282C34 !important; } | |
.c-search__input_and_close{ | |
background:#292d32!important; | |
color white !important; | |
} | |
.c-search__input_box{ | |
background:#292d32!important; | |
color white !important; | |
} | |
.c-search__input_and_close{ | |
background:#292d32!important; | |
color white !important; | |
} | |
.c-search_autocomplete{ | |
background:#b7bcbe!important; | |
color white !important; | |
} | |
.c-search_autocomplete footer{ | |
background:#97a0a5!important; | |
color white !important; | |
} | |
.c-search_autocomplete__suggestion_text{ | |
color white !important; | |
} | |
.c-search_autocomplete__suggestion_content .c-search_autocomplete__suggestion_text{ | |
color white !important; | |
} | |
.c-search_autocomplete header{ | |
background:#b7bcbe!important; | |
color:black !important; | |
} | |
.c-search_autocomplete footer .c-search_autocomplete__footer_navigation_help{ | |
color:white !important; | |
} | |
.c-search__input_box .c-search__input_box__input .ql-editor, .c-search__input_box .c-search__input_box__input .ql-placeholder{ | |
background:#2b2c2e!important; | |
border:none !important; | |
} | |
.c-search__tabs{ | |
background:#2b2c2e!important; | |
} | |
.c-search__view{ | |
background:#2b2c2e!important; | |
} | |
.c-search_message__body{ | |
color:#cacbcc !important; | |
} | |
.p-search_filter__title_text{ | |
background:#2b2c2e!important; | |
color:white !important; | |
} | |
.p-search_filter__title:before{ | |
color:grey !important; | |
} | |
.p-search_filter__dates{ | |
background:#1f2021!important; | |
border: none !important; | |
color:#cacbcc !important; | |
} | |
.p-search_filter__datepicker_trigger:hover{ | |
color:white !important; | |
} | |
.p-message_pane .c-message_list.c-virtual_list--scrollbar>.c-scrollbar__hider,.p-message_pane .c-message_list:not(.c-virtual_list--scrollbar){ | |
background:#222; | |
} | |
` | |
// 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); | |
}) | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment