Last active
August 14, 2020 15:40
-
-
Save ariankordi/f957d0d489edd59ad5e7419ca2ed7c30 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# should only need to depend on: any shell (hopefully), curl, sed, date, expr | |
# shamelessly stolen from here n modified | |
# https://web.archive.org/web/20200813201515/https://unix.stackexchange.com/questions/364776/how-to-output-a-date-time-as-20-minutes-ago-or-9-days-ago-etc/364784#364784 | |
relative() { | |
local last_unix=$(date -u --date="$1" +%s) # convert date to unix timestamp | |
local now_unix=$(date +'%s') | |
#echo "new date: $1" | |
#echo "last: $last_unix and now: $now_unix" | |
local delta=$(expr $now_unix - $last_unix) | |
local minutes=$(expr $delta / 60) | |
if [ $minutes -lt 1 ]; then | |
echo "less than a minute ago" | |
return | |
fi | |
local plural_s=s | |
if [ $minutes -eq 1 ]; then | |
plural_s= | |
fi | |
echo "$minutes minute$plural_s ago"; | |
} | |
echo "Content-Type: text/plain" | |
echo | |
# hi if you are looking at this script why are you doing that but ok! | |
# 1. correct the domain name & ua 2. enter your username 3. get the client id & client type from the app | |
response=$(curl --silent --user-agent "TextMeow/9(" "https://api.txxtnWO.me/api2.0/users/USERNAME..,.,./messages?page_size=10&client_id=CLIENT ID!!!!!&client_type=TN_IOS_REE") | |
# sorry i wanted to change the names so that because it appears this company loves to dmca | |
# takedown code from innocent people who reverse their projects completely legally lol LOL | |
# each json property becomes its own line or something idk | |
json_split=$(echo "$response" | sed 's/,"/,\n/g') | |
messages=$(echo "$json_split" | sed '/^message"/!d; s/message\":\"//') | |
dates=$(echo "$json_split" | sed '/^date"/!d; s/date\":\"//; s/Z\",/Z/g') | |
is_first_code_message_done=0 | |
is_previous_message_shown=0 | |
for i in $(seq 1 $(echo "$messages" | wc -l)); do | |
#echo "message at $(echo "$dates" | sed -n $i{p\;q}): $(echo "$messages" | sed -n $i{p\;q})" | |
message=$(echo "$messages" | sed -n $i{p\;q}) | |
# if apple id string is found then this is it, do theeeeeee | |
#echo "debgu: $is_first_code_message_done $is_previous_message_shown" | |
case $message in 'Your Apple ID Verification Code is: '*) | |
if [ $is_first_code_message_done -eq 1 ] && [ $is_previous_message_shown -eq 0 ]; then | |
echo | |
echo "previous codes:" | |
is_previous_message_shown=1 | |
fi | |
is_first_code_message_done=1 | |
date=$(echo "$dates" | sed -n $i{p\;q}) | |
# remove 't' and 'z' from this iso 8601 timestamp | |
# because it didn't work with busybox date LMOA | |
#relative $date | |
#echo $date | |
# outputs relative timestamp or whatever | |
relative "$(echo "$date" | sed 's/T/ /g; s/Z//g')" | |
# outputs code | |
echo $message | sed 's/Your Apple ID Verification Code is: //g; s/",//g' | |
# exit becau we are done | |
#exit | |
# if it's not then continue | |
;; *) continue | |
# end this case ohhh that's why it's just case in reverse lol LOL | |
;; esac | |
done | |
#echo "hiya" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment