#!/bin/bash # Updates the scripts table in README.md between SCRIPTS:START and SCRIPTS:END markers. # Scrapes @name and @description from each .user.js file in scripts/ REPO_RAW_BASE="https://git.jeirslab.xyz/jeirmeister/tampermonkey-scripts/raw/branch/master" README="README.md" # Build the table TABLE="| Script | Description | | |--------|-------------|-|" for script in scripts/*.user.js; do [ -f "$script" ] || continue name=$(grep -m1 '@name' "$script" | sed 's/.*@name\s*//') desc=$(grep -m1 '@description' "$script" | sed 's/.*@description\s*//') raw_url="${REPO_RAW_BASE}/${script}" TABLE="${TABLE} | **${name}** | ${desc} | [Install](${raw_url}) |" done # Replace everything between the markers awk -v table="$TABLE" ' // { print; print table; skip=1; next } // { skip=0 } !skip { print } ' "$README" > "${README}.tmp" && mv "${README}.tmp" "$README" echo "Updated $README"