Skip to content

Instantly share code, notes, and snippets.

@zjffun
Created January 19, 2022 09:30
Show Gist options
  • Save zjffun/fda5d97267c22bf179f1790d264ba12f to your computer and use it in GitHub Desktop.
Save zjffun/fda5d97267c22bf179f1790d264ba12f to your computer and use it in GitHub Desktop.
Download HTML
// ==UserScript==
// @name Download HTML
// @version 0.1
// @description Download HTML
// @match *://*/*
// @run-at context-menu
// ==/UserScript==
(()=>{
function download(blob, fileName) {
var a = document.createElement("a");
document.body.appendChild(a);
a.style = "display: none";
var url = window.URL.createObjectURL(blob);
a.href = url;
a.download = fileName;
a.click();
window.URL.revokeObjectURL(url);
}
download(
new Blob([document.querySelector("html").outerHTML]),
`${document.title}.html`
);
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment