Skip to content

Instantly share code, notes, and snippets.

@injust
Last active December 25, 2024 14:55
Show Gist options
  • Save injust/1292654e34ff92faf67c9f87d835fe17 to your computer and use it in GitHub Desktop.
Save injust/1292654e34ff92faf67c9f87d835fe17 to your computer and use it in GitHub Desktop.
DMOJ: Personal userscript
$(() => {
$('.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