Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@AlexApps99
Last active February 18, 2024 02:00
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AlexApps99/519c7bcef683244bd944497ce96940a2 to your computer and use it in GitHub Desktop.
Save AlexApps99/519c7bcef683244bd944497ce96940a2 to your computer and use it in GitHub Desktop.
Desmos Dark Mode
// ==UserScript==
// @name Desmos Dark Mode
// @namespace https://alexapps99.github.io/
// @version 0.3.0
// @description Improved dark mode colors for Desmos, with images and colors displayed correctly. Note: To disable dark mode being on by default, comment out line 15.
// @author AlexApps99
// @source https://gist.github.com/AlexApps99/519c7bcef683244bd944497ce96940a2
// @downloadURL https://gist.githubusercontent.com/AlexApps99/519c7bcef683244bd944497ce96940a2/raw/desmos.dark.user.js
// @match http://www.desmos.com/calculator*
// @match https://www.desmos.com/calculator*
// ==/UserScript==
setTimeout((function() {
"use strict";
// Comment out the below line to disable Dark Mode being on by default
let DARK_MODE_ON_BY_DEFAULT = true;
if (!window._ditc_old && !window._ditc_new) {
// Add styles
let s = document.createElement("style");
document.head.appendChild(s);
// For the entire screen
s.sheet.insertRule(".dcg-calculator-api-container > .dcg-container.dcg-inverted-colors { filter: invert(100%) hue-rotate(180deg) !important; }");
// For the little icon circle
s.sheet.insertRule(".dcg-calculator-api-container > .dcg-container.dcg-inverted-colors .dcg-has-background-image > .dcg-background-image { filter: hue-rotate(-180deg) invert(100%) !important; }");
// Patch image drawing code
let ditc = require("graphing/draw-image-to-ctx");
window._ditc_old = ditc.drawImageToCtx;
window._ditc_new = function(e, r, i) {
let darkMode = !!document.querySelector(".dcg-calculator-api-container > .dcg-container.dcg-inverted-colors");
if (darkMode) {
r.filter = "hue-rotate(-180deg) invert(100%)";
}
let ret = window._ditc_old.apply(this, arguments);
if (darkMode) {
r.filter = "none";
}
return ret;
}
ditc.drawImageToCtx = window._ditc_new;
}
if (typeof DARK_MODE_ON_BY_DEFAULT !== "undefined" && DARK_MODE_ON_BY_DEFAULT) {
Calc.updateSettings({
invertedColors: true
});
}
console.log("Desmos Dark Mode applied");
}), 1000);
@theswordsgame
Copy link

it does not work

@AlexApps99
Copy link
Author

The last time I updated this was 2021, so I'm not surprised!
Hopefully there are some other userscripts around that are still actively maintained.

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