Created
January 19, 2022 09:30
-
-
Save zjffun/fda5d97267c22bf179f1790d264ba12f to your computer and use it in GitHub Desktop.
Download HTML
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==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