#!/bin/mksh thread="" page="" slumber="$1" function sleep { /data/data/com.termux/files/usr/bin/sleep "$1" } function echo { /data/data/com.termux/files/usr/bin/echo -e "$(date -Im):\t$@" } if [ -z "$slumber" ]; then slumber="2m" echo "No sleep time set, defaulting to $slumber" fi function postcount { curl 'https://forums.somethingawful.com/showthread.php?threadid='$thread'&pagenumber='$page'&perpage=40' 2>/dev/null | grep -i 'author' - | grep -v 'Adbot' - | wc -l } function notify { termux-notification --priority max -c "Post count is $1" } #lastcount="$(postcount)" lastcount="20" while true; do echo "Awake, getting count!" count="$(postcount)" echo "comparing new count ($count) with last count ($lastcount)" if [ "$count" -ne "$lastcount" ]; then lastcount=$count echo "Difference found, notifying..." notify $count # if count is 38 set check time to 2m # if [ "$count" -eq "38" ]; then # slumber="2m" # echo "Set sleep time to 2m" # fi # if count is 40 notify a bunch more!! if [ "$count" -eq "40" ]; then echo "Time to post!!!" notify $count sleep 2s notify $count sleep 2s notify $count fi fi echo "sleeping..." sleep "$slumber" done