Last active
February 18, 2024 02:00
-
-
Save AlexApps99/519c7bcef683244bd944497ce96940a2 to your computer and use it in GitHub Desktop.
Desmos Dark Mode
This file contains 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
// ==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); |
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
it does not work