MPGH Codeblocks Syntax Highlight

Posts 115 of 18 · Page 1 of 2
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


Why has this hacked me Mike? UwU :3

Gj though, should come in use for many
Quote Originally Posted by Danny View Post
Why has this hacked me Mike? UwU :3

Gj though, should come in use for many
My nam joe I see beep boop code and pretend I know what’s going on
What is that good for?
True, What does it do tho ?
Adds some Improvements and I've added a Screenshot with previous - after compare
Quote Originally Posted by MikeRohsoft View Post
Adds some Improvements and I've added a Screenshot with previous - after compare
Oh I see. Seems like it's not working for me
did u removed the spaces in the Header between the @ and the rest?
Code:
// @ name MPGH Code Blocks Syntax Highlight  
// @ author Mike Rohosft
// @ grant       GM.setValue
// @ grant       GM.getValue
// @ include https://www.mpgh.net/forum/*
if i put them together, bbcode will mess it up
Code:
//  @Name MPGH Code Blocks Syntax Highlight  
//  @Author Mike Rohosft
//  @Grant       GM.setValue
//  @Grant       GM.getValue
//  @include https://www.mpgh.net/forum/*


okay, i fixed it :P u can copy it now
Quote Originally Posted by MikeRohsoft View Post
did u removed the spaces in the Header between the @ and the rest?
Code:
// @ name MPGH Code Blocks Syntax Highlight  
// @ author Mike Rohosft
// @ grant       GM.setValue
// @ grant       GM.getValue
// @ include https://www.mpgh.net/forum/*
if i put them together, bbcode will mess it up
Code:
//  @Name MPGH Code Blocks Syntax Highlight  
//  @Author Mike Rohosft
//  @Grant       GM.setValue
//  @Grant       GM.getValue
//  @include https://www.mpgh.net/forum/*


okay, i fixed it :P u can copy it now
Thanks. It works now
How about @arunforce @dave add syntax highlighting with the forum upgrade. Hahahahahahahaahhahahahaahahhahahahahahahahahahaha hahah a hahahahahahahaahhahahahaahahhahahahahahahahahahaha hahah
Quote Originally Posted by Silent View Post
forum upgrade
heh

maybe 2030
Would be nice to have this in a vb4 plugin functionality
Quote Originally Posted by Dave84311 View Post
Would be nice to have this in a vb4 plugin functionality
Just include the script, duh
Quote Originally Posted by Biesi View Post


Just include the script, duh
I thought it too xD "Can't be so difficult to find the file which adds the class 'bbcode_code' to the pre element and insert there the class 'prettyprint' + this script in the Header", but who knows, maybe it is xD
To write a vBulletin Module means PHP and my last PHP Script is 16 years ago, better not :P
damn this shit is good, finally codes with colors
Posts 115 of 18 · Page 1 of 2

Post a Reply

Similar Threads

Tags for this Thread

None

Need help?