MPGH Codeblocks Syntax Highlight
Add GreaseMonkey to your Browser Addons
create a new Script and paste this:
Code:
// ==UserScript==
// @name MPGH Code Blocks Syntax Highlight
// @author Mike Rohosft
// @grant GM.setValue
// @grant GM.getValue
// @include https://www.mpgh.net/forum/*
// ==/UserScript==
function responseHandler(text) {
GM.setValue('prettyprint', text);
const b = new Blob([text], { type: 'text/javascript' });
const u = URL.createObjectURL(b);
const script = document.createElement('script');
script.type = 'text/javascript';
script.src = u;
document.head.appendChild(script);
}
window.addEventListener('load', function init() {
const code_blocks = document.getElementsByClassName("bbcode_code");
for (let i = 0, v; v = code_blocks[i]; i++) {
if (v.tagName.toLowerCase() !== 'pre') {
continue;
}
v.classList.add('prettyprint');
}
GM.getValue('prettyprint').then(textblob => {
if (!textblob) {
fetch('https://cdn.jsdelivr.net/gh/google/code-prettify@master/loader/run_prettify.js').then(res => res.text().then(responseHandler));
} else {
responseHandler(textblob);
}
});
window.removeEventListener('load', init);
});
save it
reload
