From Chickenfoot Script Repository
// ==UserScript==
// @name Dump current HTML
// @when Pages Match
// @description writes html of current page to a local file
// @include *
// ==/UserScript==
/**
* Run this script to dump the current HTML of the web
* page being displayed into a local file.
* <SCRIPT> tags are stripped as they may call
* functions that would generate duplicate HTML
*/
fileName = "c:\\calendar.html";
include("fileio.js");
include("prototype.js");
include("scriptaculous/builder.js");
base = Builder.node("base",
{href : document.location.toString().match(/(.*\/)[^\/]*/)[1]});
head = document.getElementsByTagName("head")[0];
head.insertBefore(base, head.firstChild);
for (var tbox in find("textbox")) {
tbox.element.setAttribute("value", tbox.element.value)
}
for (var pbox in find("password")) {
pbox.element.setAttribute("value", pbox.element.value)
}
var html = document.documentElement.innerHTML;
html = html.stripScripts();
var dt = document.doctype;
var doctypeDef = (dt) ? '<!DOCTYPE ' + dt.name + ' PUBLIC "' +
dt.publicId + '" "' + dt.systemId + '">' : "";
html = doctypeDef + '<html>' + html + '</html>';
write(fileName, html);
output("Wrote file to: " + fileName);