Skip to content

Instantly share code, notes, and snippets.

@DrewML
Last active January 25, 2022 00:53
Show Gist options
  • Save DrewML/0acd2e389492e7d9d6be63386d75dd99 to your computer and use it in GitHub Desktop.
Save DrewML/0acd2e389492e7d9d6be63386d75dd99 to your computer and use it in GitHub Desktop.
Theming Slack for OSX

Theming Slack for OSX

So, you love Slack, but you hate applications with large white backgrounds? Why not use Dark Mode!

Unfortunately, Slack does not have a Dark Mode, although it's on their list of possibilities.

But, don't fret - there is a solution! Because the slack native desktop apps are just wrappers around a web app, we can inject our own CSS to customize the application to our liking.

How to (OSX Only)

Prerequisite Your custom CSS needs to be hosted somewhere accessible over HTTP. For a free option, you can use a Gist and use the link to the raw file.

  1. Open up Slack.app, and navigate to any message;
  2. In the message input field, enter /macgap.app.enabledevelopertools(), and press enter
  3. Right click any element in the app (except the team switcher on the left), and choose Inspect Element
  4. Open the Console tab
  5. Run the following snippet of JavaScript in your console, replacing the value of cssURI with the URI that points to your custom stylesheet.
// Using ajax rather than a dynamically injected <link>, to account for sites (like gist.github.com) that don't serve
// a content-type for CSS files
var cssURI = 'https://gist.githubusercontent.com/DrewML/f244d6015c9b690b1dc241669b69dde1/raw/3d6351b8767ee5fba1ac86cad9b8cc5cf2ff9fea/slack-theme.css';
$.get(cssURI).then(function(css) {
   $('<style />').text(css).appendTo('body')
});

Example Dark Theme

image

Writing your own theme

If you know the basics of CSS and browser developer tools, writing a theme should be a breeze. You can either use the Developer Tools exposed in the Slack application itself, or you can visit https://{myteamhere}.slack.com/messages and use the browser dev tools of your choosing.

The part that's a bummer

Because you're just injecting styles in the DOM, this means that your changes do not persist when you exit and re-open the application. However, the Developer Tools will remember the last code you executed, so it should be a few keystrokes to open the panel and re-run your injection script.

@hackel
Copy link

hackel commented Apr 17, 2018

FYI - fix for the latest changes is here: laCour/slack-night-mode#73 (comment)

@jorgeorpinel
Copy link

jorgeorpinel commented Jun 7, 2018

I get "/macgap.app.enabledevelopertools() is not a valid command." no matter what I do. I tried to set the SLACK_DEVELOPER_MENU env var in all the ways mentioned above.

@jorgeorpinel
Copy link

I get "/macgap.app.enabledevelopertools() is not a valid command." no matter what I do. Tried to set the SLACK_DEVELOPER_MENU env var in all the ways mentioned above.

@danilodequeiroz
Copy link

Use this instead.

@micnguyen
Copy link

@danilodequeiroz That works great. Thanks for that. Incredible that Slack has not properly addressed this yet.

@KrishMehta
Copy link

@danilodequeiroz that's fantastic; however, I think it'd be better if your link color (and maybe tags as well) was changed to #0000EE instead of the stale gray that it currently is. Again, just my opinion - but I think a lot of people would like it better.

@willhayslett
Copy link

willhayslett commented Aug 27, 2018

If using the solution provided by @danilodequeiroz, you'll notice the menu links are hard to see. Use the following script to make the text white:

document.addEventListener('DOMContentLoaded', function() {
  let tt__customCss = `.menu ul li a:not(.inline_menu_link) {color: #fff !important;}`
  $.ajax({
      url: 'https://cdn.rawgit.com/laCour/slack-night-mode/master/css/raw/black.css',
      success: function(css) {
          $("<style></style>").appendTo('head').html(css + tt__customCss);
      }
  });
});

@brennenawana
Copy link

Just want to say that this is awesome, just what I was looking for. Thanks so much for sharing.

@UiCandy
Copy link

UiCandy commented Nov 13, 2018

Legend, finally my eyes can rest on Mojave. 😃

@ryanpcmcquen
Copy link

I wrote a script I can run each time Slack updates: https://gist.github.com/ryanpcmcquen/8a7ddc72460eca0dc1f2dc389674dde1

@bh2smith
Copy link

@danilodequeiroz worked immediately! Amazing!

@rocajuanma
Copy link

@danilodequeiroz thank you!

@XLPI
Copy link

XLPI commented Jan 2, 2019

/macgap.app.enabledevelopertools() is not a valid command. In Slack, all messages that start with the "/" character are interpreted as commands.

If you are trying to send a message and not run a command, try preceding the "/" with an empty space.

What can I do?

@garyray-k
Copy link

@XLPI
Just got the same. I did an update and... :(
Commenting to follow while I dig into it a bit.

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