Last active
March 2, 2018 11:42
-
-
Save rsKliPPy/31c9ad9426794a34f08270e602c12834 to your computer and use it in GitHub Desktop.
ViolentMonkey script that highlights [code] blocks on AlliedModders Forums
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 AlliedModders Code Highlight | |
// @description Adds syntax highlight for [code] blocks on AlliedModders Forums | |
// @namespace github.com/rsKliPPy | |
// @match https://forums.alliedmods.net/* | |
// @version 1.0.2 | |
// @downloadURL https://gist.github.com/rsKliPPy/31c9ad9426794a34f08270e602c12834/raw/am-code-highlight.user.js | |
// @homepageURL https://github.com/rsKliPPy | |
// @run-at document-end | |
// | |
// @resource hljsScript https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min.js | |
// @resource hljsStyleSheet https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/vs.min.css | |
// | |
// @grant GM_addStyle | |
// @grant GM_getResourceText | |
// ==/UserScript== | |
'use strict'; | |
GM_addStyle(GM_getResourceText('hljsStyleSheet')); | |
const scriptElement = document.createElement('script'); | |
scriptElement.type = 'text/javascript'; | |
scriptElement.appendChild(document.createTextNode(GM_getResourceText('hljsScript'))) | |
document.body.appendChild(scriptElement); | |
hljs.configure({ | |
tabReplace: ' ', // 1 tab = 4 spaces | |
languages: [ 'markdown', 'json', 'xml', 'python', 'cpp' ] | |
}); | |
window.addEventListener('load', () => { | |
for(const element of document.querySelectorAll('pre.alt2')) { | |
hljs.highlightBlock(element); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment