chadtmiller.com/knotless

Git hosted in your atproto account, on any stock PDS, fast enough for agents.

git clone knotless://chadtmiller.com/knotless

needs the knotless git helper. set it up

main
17 lines · 803 B Raw History
// What a page's screenshot follows from: its HTML, which carries the
// styles and scripts too, less what differs between worlds: DIDs, the
// record keys in links to pulls and issues, and the port it is served on.

import { createHash } from 'node:crypto'

export const digest = (html) =>
  createHash('sha256')
    .update(html.replace(/did:plc:[a-z2-7]{24}/g, 'did').replace(/127\.0\.0\.1:\d+/g, 'host').replace(/\/[2-7a-z]{13}(?=["/?#])/g, '/rkey'))
    .digest('hex')

/// The path of the social card a page names, which carries a hash of what
/// the card shows: all its pixels follow from, but the renderer.
export const card = (html) => {
  const url = html.match(/<meta property="og:image" content="([^"]+)"/)[1].replaceAll('&amp;', '&')
  return new URL(url).pathname + new URL(url).search
}