#!/bin/bash
###################################################################### 
#Copyright (C) 2023  Kris Occhipinti
#https://filmsbykris.com

#This program is free software: you can redistribute it and/or modify
#it under the terms of the GNU General Public License as published by
#the Free Software Foundation version 3 of the License.

#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#GNU General Public License for more details.

#You should have received a copy of the GNU General Public License
#along with this program.  If not, see <http://www.gnu.org/licenses/>.
###################################################################### 

domain="https://receive-smss.com"

function get_number(){
  wget -qO- "${domain}"|\
    grep number-boxes-itemm-number|\
    grep '+'|\
    cut -d\+ -f2|cut -d\< -f1|\
    fzf --prompt="Select a Number: "
}

function get_messages(){
  wget -qO- "${domain}/sms/${number}/"|\
    grep -A1 wr3pc32233el1878|\
    sed -e 's/<[^>]*>//g'|\
    tr -d "\n"|sed 's/--/\n/g'|\
    grep ago -B1
}

number="$(get_number)"
[[ $number ]] || exit

echo "$number"|xclip
echo "Number Selected $number and added to clipboard."
read -p "Press Enter to Continue..."

get_messages|less
