Skip to content

Instantly share code, notes, and snippets.

@Sarverott
Last active September 11, 2025 07:48
Show Gist options
  • Save Sarverott/47042225a00aee1e8b925de620d7b986 to your computer and use it in GitHub Desktop.
Save Sarverott/47042225a00aee1e8b925de620d7b986 to your computer and use it in GitHub Desktop.
"darkpointWebsiteInprint"
function inprint(){
return {
label:window.document.title,
url:window.location.href,
metadata:getMetaFromHead(),
checksum:based64sha1ofWebsite(),
refers:linkedUrlsMap()
}
}
function getMetaFromHead(){
return Object.fromEntries(
new Map(
Array.from(
document.head.querySelectorAll("meta")
).map(
(x)=>[
x.getAttribute("name")
||
x.getAttribute("property"),
x.getAttribute("content")
]
).filter(
(
(x)=>
x[0]!==null
&&
x[1]!==null
)
)
)
)
}
function linkedUrlsMap(){
return Object.fromEntries(
new Map(
Array.from(
document.querySelectorAll("a")
).filter(
(x)=>x.getAttribute("href")!==null
).map(
(x)=>[
x.href,
x.innerText
]
)
)
)
}
function based64sha1ofWebsite(){
return `!b64sha1<h:${
btoa(
Array.from(
new Uint8Array(
await window.crypto.subtle.digest(
"SHA-1",
(
new TextEncoder()
).encode(
document.body.outerHTML
)
)
)
).map(
(x)=>String.fromCharCode(x)
).join("")
)
}&l:${
document.body.outerHTML.length
}B`;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment