I need a way to take a web page that's already loaded in the page and save the page's full DOM (as an HTML string) such that were I to load the HTML offline as a single file, it would preserve the effects of all CSS and whatever scripts had been run prior to saving it. Keeping the images would be a bonus, but even having them missing but with a placeholder so that the layout is preserved is fine.
The catch is I can't reload or requery any of the resource files (JS/CSS). Fonts are not important.
This means the resulting HTML can't refer to external files. Is this even possible using just JavaScript?
EDIT:
1) This needs to be a programmatic solution using JavaScript, not a browser UI solution.