The following couple of commands will clear out all the HTML and any CSS style sheets.
document.body = document.createElement('body'); // This creates a new body element document.head.innerHTML = ''; // This clears the head element
One is still left with any Javascript code which is present. Haven’t found an easy way to clear that yet.