Skip to content

Instantly share code, notes, and snippets.

@selimhex
Created November 9, 2025 18:35
Show Gist options
  • Select an option

  • Save selimhex/8bae24667ffe3da300954e9307b15937 to your computer and use it in GitHub Desktop.

Select an option

Save selimhex/8bae24667ffe3da300954e9307b15937 to your computer and use it in GitHub Desktop.
# creates a bookmarklet from a js file (uses terser - initialized with bun)
# https://github.com/terser/terser
# https://bun.sh/
bookmarkletter() {
local path=${1:-""}
if [[ -z $path ]]; then
echo "no path specified!"
exit 0
fi
if [[ ! -f $path ]]; then
echo "js file doesn't exist!: $path"
exit 0
fi
local val=$(bunx terser $1 -c -m)
echo "javascript:(function(){ $val }());"
}
bookmarkletter ${*}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment