Skip to content

Instantly share code, notes, and snippets.

@DarrenSem
Created December 1, 2022 01:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DarrenSem/0f0dfbb34b97026aac5bd50aa57b7da3 to your computer and use it in GitHub Desktop.
Save DarrenSem/0f0dfbb34b97026aac5bd50aa57b7da3 to your computer and use it in GitHub Desktop.
HTML.js - display full webpage source (document.documentElement.outerHTML) into a new tab popup
// HTML.js - display full webpage source (document.documentElement.outerHTML) into a new tab popup
// RUN = 304 char: javascript:void function(){let a=open("about:blank").document,b=a.body;b.appendChild(a.createElement("b")).innerText=a.title=`Source code of ${location.href}`;let c=b.appendChild(a.createElement("pre"));c.innerText=document.documentElement.outerHTML,c.style.whiteSpace="pre-wrap",c.style.color="blue"}();
let doc = open('about:blank').document;
let body = doc.body;
let tagForTitle = "b";
body.appendChild(doc.createElement(tagForTitle)).innerText = doc.title = `Source code of ${location.href}`;
let pre = body.appendChild(doc.createElement("pre"));
let color = "blue";
pre.innerText = document.documentElement.outerHTML;
pre.style.whiteSpace = 'pre-wrap'; // overflow: 'auto', // apparently overflow is no longer needed?
pre.style.color = color;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment