Skip to content

Instantly share code, notes, and snippets.

@shvelo
Last active August 29, 2015 13:56
Show Gist options
  • Save shvelo/9333755 to your computer and use it in GitHub Desktop.
Save shvelo/9333755 to your computer and use it in GitHub Desktop.
Replace Body content with HTML source
(function(){
var code_container = document.createElement("div");
code_container.id = "code_container";
code_container.innerText = document.documentElement.innerHTML;
code_container.innerHTML = "<pre><code>"+ code_container.innerHTML + "</code></pre>";
document.body.appendChild(code_container);
// More at https://github.com/isagalaev/highlight.js/tree/master/src/styles
var theme = window.highlight_theme || "solarized_dark";
var stylesheet = document.createElement("link");
stylesheet.rel = "stylesheet";
stylesheet.href = "https://yandex.st/highlightjs/8.0/styles/"+ theme +".min.css";
document.head.appendChild(stylesheet);
var stylesheet2 = document.createElement("style");
stylesheet2.innerHTML = "#code_container { height: 100%; width: 100%; box-sizing: border-box; position: absolute; top: 0; left: 0; padding: 1em; }\n"
+ "#code_container pre { height: 100%; box-shadow: 0 0 10px black; overflow: auto; padding: 0; margin: 0; word-wrap: break-word; line-height: 1.6; font-size: 16px }";
document.head.appendChild(stylesheet2);
var script = document.createElement("script");
script.onload = function(){ hljs.initHighlighting(); };
script.src = "https://yandex.st/highlightjs/8.0/highlight.min.js";
document.head.appendChild(script);
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment