satosa-ph

Launched an MVP that made it to the front page of Product Hunt, by offering a service that manages agreements on your websites and apps with a low-friction click to accept e-signature alternative.
git clone https://unitehenry.com/git/satosa-ph.git
Log | Files | Refs | README

capture.sh (1402B)


      1 #!/usr/bin/env bash
      2 # Capture a Product Hunt product page as a single self-contained HTML file.
      3 #
      4 # Usage:
      5 #   ./capture.sh [url] [output.html]
      6 #
      7 # Requires a real (headed) Chromium: Product Hunt sits behind Cloudflare and
      8 # a headless browser stalls on the Turnstile challenge.
      9 set -euo pipefail
     10 
     11 HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
     12 URL="${1:-https://www.producthunt.com/products/satosa}"
     13 OUT="${2:-$HERE/dist/satosa-producthunt.html}"
     14 
     15 mkdir -p "$(dirname "$OUT")"
     16 
     17 npx --yes single-file-cli \
     18   --browser-headless=false \
     19   --browser-executable-path="${CHROMIUM:-/usr/bin/chromium}" \
     20   --browser-arg="--no-sandbox" \
     21   --browser-wait-until=networkIdle \
     22   --browser-load-max-time=90000 \
     23   --browser-capture-max-time=90000 \
     24   --browser-wait-delay=6000 \
     25   --browser-script="$HERE/expand.js" \
     26   --filename-conflict-action=overwrite \
     27   --insert-meta-noindex \
     28   --console-messages-file="$HERE/dist/console.json" \
     29   "$URL" "$OUT"
     30 
     31 # expand.js leaves a dead "see less" / "Show less" toggle behind; drop it
     32 sed -z -E -i 's#<button\b[^>]*>[[:space:]]*(see|show)[[:space:]]+less[[:space:]]*</button>##Ig' "$OUT"
     33 grep -qiE '>(see|show) less<' "$OUT" && echo "warning: dead toggle still present" >&2
     34 
     35 # publish a copy next to the script as index.html, so GitHub Pages serves it
     36 PUBLISHED="$HERE/index.html"
     37 [ "$OUT" -ef "$PUBLISHED" ] || cp "$OUT" "$PUBLISHED"
     38 
     39 echo "wrote $PUBLISHED"