Skip to content

Instantly share code, notes, and snippets.

@colejd
Last active March 30, 2023 16:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save colejd/1da7c341164107e7de6a3b93cc951bc9 to your computer and use it in GitHub Desktop.
Save colejd/1da7c341164107e7de6a3b93cc951bc9 to your computer and use it in GitHub Desktop.
Stylus userstyle that fixes Basecamp Tracked in dark mode on Firefox
@-moz-document regexp("https:\\/\\/3.basecamp.com\\/.+#board") {
/*
* This is a CSS file that cleans up the look of Tracked for Basecamp on Dark Mode in Firefox (and probably other browsers).
* First, on Basecamp go to your settings and change the theme to dark mode or light mode - not auto.
* Auto doesn't set data-color-scheme, which Tracked uses to color its own components.
* Next, Install Stylus, then create a new style. Click "Import" in the top-left and paste this code in.
*/
:root {
--custom-bg: white;
}
[data-color-scheme="dark"] {
--custom-bg: #272f3e;
}
.new_todo_form select,
.new_todo_form textarea {
background: var(--custom-bg);
color: var(--hljs-text);
}
}
@-moz-document regexp("https:\\/\\/3.basecamp.com\\/.+\\/todos\\/.+") {
:root {
--custom-list-bg: white;
--custom-list-fg: black;
--custom-list-hover: #508bff;
}
[data-color-scheme="dark"] {
--custom-list-bg: #272f3e;
--custom-list-fg: white;
--custom-hover: #a1baeb;
}
.input_mini_modal_list .choose_new_list {
background-color: var(--custom-list-bg) !important;
}
#kanban_list.input_mini_modal_list {
background-color: var(--custom-list-bg) !important;
}
#kanban_list.input_mini_modal_list tr.selected {
text-decoration: underline;
color: var(--hljs-text) !important;
}
#kanban_list.input_mini_modal_list tr:hover {
color: var(--custom-list-hover) !important;
}
.kanban_list_name span {
color: var(--custom-list-fg) !important;
}
.kanban_list_name span:hover {
color: var(--custom-list-hover) !important;
}
}
@colejd
Copy link
Author

colejd commented Mar 30, 2023

As stated above, you'll want to set Basecamp itself to be either light or dark mode, but not "Same as OS". If you want it to automatically switch, install this ViolentMonkey script:

// ==UserScript==
// @name        Fix data-color-scheme for Tracked when Auto theme is enabled - basecamp.com
// @namespace   Violentmonkey Scripts
// @match       https://3.basecamp.com/*
// @grant       GM_addElement
// @version     1.0
// @author      -
// @description 
// @run-at      document-end
// ==/UserScript==

/*
 * Sets data-color-scheme on the <html> element based on the browser's theme. This
 * fixes Tracked. Don't use the Auto color scheme!
 */

let el = GM_addElement(
  document.body,
  'script',
  {
    textContent: `
      function delay(time) {
        return new Promise(resolve => setTimeout(resolve, time));
      }

      function setDarkMode() {
        if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
          document.documentElement.setAttribute("data-color-scheme", "dark");
        } else {
          document.documentElement.setAttribute("data-color-scheme", "light");
        }
      }

      setDarkMode();
      delay(500).then(() => setDarkMode());

      // Set up listener for dark mode change
      window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', event => {
        document.documentElement.setAttribute("data-color-scheme", event.matches ? "dark" : "light");
      });
    `,
    defer: true

  }
);

It's not pretty, and the wrong theme will flash on screen for a bit, but it works for me.

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