Last active
August 9, 2021 08:04
-
-
Save jcwillox/80ca215c2c860f8a15fdbc5a0372ef59 to your computer and use it in GitHub Desktop.
Make plain HTML pages on iLearn fancy
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
// ==UserScript== | |
// @name iLearn HTML Beautify | |
// @version 0.2.1 | |
// @description Make plain HTML pages on iLearn fancy | |
// @author jcwillox | |
// @license MIT | |
// @include https://ilearn.mq.edu.au/pluginfile.php/*.html | |
// @include https://ilearn.mq.edu.au/pluginfile.php/*.htm | |
// @run-at document-start | |
// @grant GM_addStyle | |
// @grant GM_getResourceText | |
// @require https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.2.0/highlight.min.js | |
// @require https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.2.0/languages/scala.min.js | |
// @require https://gist.githubusercontent.com/jcwillox/b790653f57572cf1c23dfd5f3e133c32/raw/log-version.js | |
// @resource code-theme https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.2.0/styles/base16/material-palenight.min.css | |
// @noframes | |
// ==/UserScript== | |
const STYLES = ` | |
@import url('https://fonts.googleapis.com/css?family=Inter:100,200,300,400,500,600,700,800,900&display=swap'); | |
body { | |
background-color: #1B1E2B; | |
font-family: 'Inter', sans-serif; | |
color: #EFEFEF; | |
scroll-behavior: smooth; | |
max-width: 1200px; | |
margin: auto; | |
padding: 8px; | |
} | |
code { | |
font-size: .9rem; | |
font-family: 'Fira Code', ui-monospace, SFMono-Regular, SF Mono, Menlo, Consolas, Liberation Mono, monospace; | |
} | |
a { | |
color: inherit; | |
} | |
.back, h1 { | |
color: rgb(28, 149, 224); | |
} | |
h2 { | |
color: rgb(108, 185, 233); | |
} | |
h3 { | |
color: rgb(157, 209, 241); | |
} | |
`; | |
/* ensure pre blocks are pre > code */ | |
document.querySelectorAll("pre").forEach(el => { | |
if (el.children.length === 0) { | |
let codeEl = document.createElement("code"); | |
codeEl.innerHTML = el.innerHTML; | |
codeEl.className = "language-scala"; | |
el.innerHTML = ""; | |
el.appendChild(codeEl); | |
} | |
}); | |
GM_addStyle(STYLES); | |
GM_addStyle(GM_getResourceText("code-theme")); | |
hljs.configure({cssSelector: "code"}); | |
hljs.highlightAll(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment