Show HN: A Raycast script for the HN bookmarklet
Since Arc doesn't have bookmarks, this became the best way for me to post.
``` #!/bin/bash
# Required parameters:
# @raycast.schemaVersion 1
# @raycast.title Submit to Hacker News
# @raycast.mode fullOutput
# Optional parameters:
# @raycast.icon ./images/yc.png
# @raycast.packageName Web Tools
# @raycast.argument1 { "type": "text", "placeholder": "URL to submit", "percentEncoded": false }
# Documentation:
# @raycast.description Submit a URL to Hacker News with the current page title.
# @raycast.author DigitalNoumena
# Extract the <title> tag
page_title=$(curl -sL "$1" | sed -n 's:.*<title>\(.*\)</title>.*:\1:p')
# If no title is found:
if [ -z "$page_title" ]; then
page_title="No title found"
fi
# URL encode the title and the URL
encoded_url=$(echo -n "$1" | jq -sRr @uri)
encoded_title=$(echo -n "$page_title" | jq -sRr @uri)
# Open the Hacker News submission page with the encoded URL and title
open "https://news.ycombinator.com/submitlink?u=$encoded_url&t=$encoded_title"
``` No comments yet.