Skip to content

Instantly share code, notes, and snippets.

@Rachniotov
Last active September 6, 2022 09:50
Show Gist options
  • Star 10 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Rachniotov/ce46a452cdbf9c4d8552615c76aa3aac to your computer and use it in GitHub Desktop.
Save Rachniotov/ce46a452cdbf9c4d8552615c76aa3aac to your computer and use it in GitHub Desktop.
Darkmode for Mongodb Compass!

Introduction

So I used Mongodb Compass for a little time a few months ago and then i switched to another mongo client gui for the sole reason, Darkmode. That mongo client was good but recently it became paid. I then switched back to Compass but my eyes couldnt take it 😩

Then I spent some time researching what could I do to make compass darker and easier to read and I found this npm package for the Darkreader chrome plugin. I knew that compass was made in Electron as it had .asar files in its source, that means I could easily implemt that npm package into the Electron app.

Here is the result! preview

How to

make sure you have latest NodeJS and NPM installed on your machine

The following steps would be for linux but replicating it on windows would be easy too

  1. First locate the directory where MongoDb Compass is installed, in my case it is /usr/lib/mongodb-compass, cd into the resources directory

  2. run npx asar extract app.asar dest_dir

  3. Add a new JavaScript file in dest_dir/src/app (dest_dir/build for MacOS) called darkreader.js (you change the name too) and paste the contents of this file inside it. append these lines of code at the very end of the file:

    DarkReader.enable({
        brightness: 100,
        contrast: 90,
        sepia: 20
    });

    you can ofc play with these values to get the taste you want.

  4. find an index.html in the same directory and add the following lines just before </body>:

    <script src="darkreader.js" charset="UTF-8" async></script>
  5. save all the changes then cd into dest_dir run npx asar pack . app.asar, this will pack the code back into an .asar file

  6. Backup the app.asar inside /usr/lib/mongodb-compass/resources and then run mv app.asar /usr/lib/mongodb-compass/resources

  7. Restart Compass and enjoy the theme :)

@arashseyedi
Copy link

@soulninja-dev The Dark Theme is already included in the latest MongoDB Compass (version 1.30.1), under View > Theme
https://www.mongodb.com/try/download/compass

@i-zanis
Copy link

i-zanis commented Jan 28, 2022

Many thanks on this.

@JosueJMartinez
Copy link

Ah my bad but thanks @JosueJMartinez for pointing this out! really appreciate it.

np!

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