Created
December 1, 2022 01:15
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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