Last active
December 25, 2024 14:55
-
-
Save injust/1292654e34ff92faf67c9f87d835fe17 to your computer and use it in GitHub Desktop.
DMOJ: Personal userscript
This file contains hidden or 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
$(() => { | |
$('.anime-img').show() | |
// Dark mode for native HTML elements | |
const colorScheme = $('<meta>').attr({ | |
name: 'color-scheme', | |
content: 'light dark' | |
}) | |
$('head').append(colorScheme) | |
// Highlight trailing whitespace (from https://dmoj.ca/user/d) | |
const f = s => `<span style="background-color: rgba(247, 196, 0, 0.5)">${s}</span>` | |
$('code').html((i, obj) => obj | |
.replaceAll(/\w +\S/g, s => s[0] + f(s.slice(1, -1)) + s.slice(-1)) | |
.replaceAll(/ +\n/g, s => `${f(s.slice(0, -1))}\n`) | |
.replaceAll(/ +$/g, s => `${f(s)}\n`)) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment