Gradescope Dark Mode

Invert color of PDF viewer. Adjust brightness via -/+ keys.

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

You will need to install an extension such as Tampermonkey to install this script.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

You will need to install an extension such as Tampermonkey to install this script.

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

Advertisement:

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

Advertisement:

// ==UserScript==
// @name         Gradescope Dark Mode
// @namespace    http://tampermonkey.net/
// @version      0.2
// @description  Invert color of PDF viewer. Adjust brightness via -/+ keys.
// @author       Erik Demaine
// @match        https://www.gradescope.com/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=gradescope.com
// @grant        none
// @license      MIT
// @website      https://github.com/edemaine/dark-monkey
// ==/UserScript==

(function() {
    let brightness = 1;
    const style = document.createElement('style');
    style.type = 'text/css';
    document.head.appendChild(style);

    const update = () => style.innerText = `.pv--viewer img { filter: invert(1) hue-rotate(180deg) brightness(${brightness}) }`;
    update();

    window.addEventListener('keydown', (e) => {
        if (e.key === '+' || e.key === '=') {
            brightness += 0.1;
            update();
        } else if (e.key === '-' || e.key === '_') {
            brightness -= 0.1;
            if (brightness < 0.1) brightness = 0.1;
            update();
        }
    });
})();