Created
April 10, 2013 15:00
-
-
Save johnboxall/5355380 to your computer and use it in GitHub Desktop.
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> | |
<head> | |
<script> | |
/** | |
* In 1s, `onError` will be called to 'recover' the original document. | |
*/ | |
onError = function() { | |
var s; | |
while (s = document.scripts[0]) s.parentNode.removeChild(s); | |
var openingHTMLTag = openingTag(document.documentElement); | |
var headEl = $$('head')[0]; | |
var openingHeadTag = openingTag(head); | |
var headInnerHTMLandClosingTag = head.innerHTML; | |
var bodyOuterHTML = $$('plaintext')[0].innerText; | |
document.open(); | |
document.write(openingHTMLTag, openingHeadTag, headInnerHTMLandClosingTag, bodyOuterHTML); | |
document.close(); | |
} | |
function openingTag(el) { | |
var tagName = el.tagName; | |
return el.cloneNode(false).outerHTML.replace(RegExp('</' + tagName + '>$','i'), '\n'); | |
} | |
function $$(tag) { | |
return document.getElementsByTagName(tag); | |
} | |
setTimeout(onError, 1000); | |
</script> | |
<title>Capturing Recovery Test</title> | |
<plaintext> | |
</head> | |
<body> | |
<h1>Capturing Recovery Test</h1> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment