Skip to content

Instantly share code, notes, and snippets.

@imring
Last active May 18, 2021 16:02
Show Gist options
  • Save imring/f102634c2508b8221013c1b325d27676 to your computer and use it in GitHub Desktop.
Save imring/f102634c2508b8221013c1b325d27676 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name bh + highlight.js
// @namespace https://www.blast.hk/
// @author imring
// @match https://www.blast.hk/attachments/*/plain
// @icon https://www.google.com/s2/favicons?domain=blast.hk
// @require https://code.jquery.com/jquery-3.6.0.min.js
// @require https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.7.1/highlight.min.js
// @require https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.7.1/languages/go.min.js
// @resource IMPORTED_CSS https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.7.1/styles/stackoverflow-dark.min.css
// @grant GM_getResourceText
// @grant GM_addStyle
// ==/UserScript==
$(document).ready(function() {
const my_css = GM_getResourceText("IMPORTED_CSS");
GM_addStyle(my_css);
let pre = $("body").find("pre");
let text = pre.text();
pre.remove();
$("body").append(`<pre><code>${text}</code></pre>`);
hljs.highlightBlock($("body").find("pre code").get(0));
let bgcolor = $(".hljs").css("background");
$("body, pre").css({
"margin": "0",
"padding": "0",
"background": bgcolor,
"word-wrap": "break-word",
"white-space": "pre-wrap"
});
});
(function() {
'use strict';
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment