Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- javascript: /*DOMSnapshot*/ (rl => {
- function htm(t, m, a, x) {
- if(document.head && !document.head.querySelector("base")) {
- (x = document.createElement("BASE")).href = location.href.split("?")[0];
- document.head.appendChild(x)
- } else x = null;
- t = true;
- m = Array.from(document.childNodes).map((nd, i) => {
- switch (nd.nodeType) {
- case Node.COMMENT_NODE:
- case Node.TEXT_NODE:
- return `<!--${nd.data}-->\n`;
- case Node.ELEMENT_NODE:
- return nd.outerHTML + "\n";
- case Node.DOCUMENT_TYPE_NODE:
- t = !(nd.publicId || nd.systemId);
- return `<!${(/\bxml\b/).test(document.contentType) ? "DOCTYPE" : "doctype"} ${nd.name}${
- nd.publicId ? ` PUBLIC "${nd.publicId}"` : ""
- }${nd.systemId ? ` "${nd.systemId}"` : ""}>\n`;
- default:
- console.log("Unprocessed node", nd);
- return `<!--(NodeType${nd.nodeType})-->\n`
- }
- });
- if (document instanceof XMLDocument) m.unshift(
- `<?xml version="1.0" encoding="${document.characterSet}" standalone="${t ? "yes" : "no"}"?>\n`
- );
- rl.forEach(r => {
- r[1].parentNode.insertBefore(r[0], r[1]);
- r[1].parentNode.removeChild(r[1])
- });
- a = document.createElement("A");
- a.href = URL.createObjectURL(new Blob([
- '<!doctype html>\n<body style="white-space:pre;font-family:monospace">\n' + m.join("").replace(/</g, "<") + '</body>'
- ], {type: "text/html"}));
- if(x) x.parentNode.removeChild(x);
- if(t = document.title) {
- x = {
- "\"": "\u201c",
- "*": "\u20f0",
- "/": "-",
- ":": "\ua789",
- "<": "\u2264",
- ">": "\u2265",
- "?": "\xbf",
- "\\": "-",
- "|": "\u2502"
- };
- t = t.replace(/["*\/:<>?\\|]/g, c => x[c]) + " - "
- }
- m = (m = location.pathname.match(/\/([^\/]+)$/)) ? m[1] : "";
- a.target = "_blank";
- if(a.click) {
- a.click()
- } else open(a.href, "_blank")
- }
- function subsEle(ri, u, h, e) {
- e = document.createElement(rl[ri].href ? "style" : "script");
- e.setAttribute("source", u);
- e.innerHTML = h;
- rl[ri] = [rl[ri], e];
- rl[ri][0].parentNode.insertBefore(e, rl[ri][0]);
- rl[ri][0].parentNode.removeChild(rl[ri][0]);
- if(++ri < rl.length) {
- getRes(ri)
- } else htm()
- }
- function getRes(ri, u) {
- u = rl[ri].href || rl[ri].src;
- console.log("Fetching: " + u);
- fetch(u).catch((er, e) => {
- console.log("Error fetching: " + u, er);
- alert(`Error fetching:\n${u}\n\n${er}`);
- subsEle(ri, u, `/* ${er} */`)
- }).then(r => r.text()).then((t, e) => {
- console.log("Fetched: " + u);
- subsEle(ri, u, t)
- });
- }
- rl = Array.from(document.querySelectorAll("link[href][rel=stylesheet],script[src]")).filter(e => e.href || e.src);
- if(rl.length) {
- getRes(0)
- } else htm()
- })()
Add Comment
Please, Sign In to add comment