Perhaps something like this? It's probably not very cross-browser however, but it works in Chrome.
function downloadCurrentDocument() {
var base64doc = btoa(unescape(encodeURIComponent(document.documentElement.innerHTML))),
a = document.createElement('a'),
e = new MouseEvent('click');
a.download = 'doc.html';
a.href = 'data:text/html;base64,' + base64doc;
a.dispatchEvent(e);
}
downloadCurrentDocument();