#!/bin/bash

# Set the window title
printf "\e]0;Love and Corruption - Unlocker by Mistress.Ayin\a"

# Print welcome message
echo -e "\e[1;35mWelcome to Love and Corruption - Unlocker, by Mistress.Ayin !\e[0m"
echo # Put an ENTER

# Print note
echo -e "\e[1;31mNote: if you have an ERROR, or the script can not found the files, Do NOT run the script again, and more IMPORTANT: you must have only one HTML main file in the game root folder.\e[0m"
echo # Put an ENTER

# Print warning message
read -p $'\e[1;33mDo you want to continue ? (press "y" to continue) \e[0m' -n 1 -r
echo # Put an ENTER
if [[ $REPLY =~ ^[Yy]$ ]]; then
    echo # Put an ENTER
    echo "Continue to running the script ..."
else
    exit
    echo # Put an ENTER
fi

# Showing file path.
echo # Put an ENTER
echo 'You can find codes in the game root folder, at the "unlock-codes.txt" file too.'; echo # Put an ENTER

# Finding the Gallery code.
echo "Gallery Unlock:" >> unlock-codes.txt; cat "$PWD"/*.[Hh][Tt][Mm][Ll] | grep -o '_topBackerTier=[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]' | grep -o '[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]' >> unlock-codes.txt
echo "---------------" >> unlock-codes.txt

# Finding the Bonus Scenes code.
echo "Bonus Scenes:" >> unlock-codes.txt; cat "$PWD"/*.[Hh][Tt][Mm][Ll] | grep -o '_warmedFeed=[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]' | grep -o '[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]' >> unlock-codes.txt
echo "---------------" >> unlock-codes.txt

# Finding the Cheats code.
echo "Cheats Unlock:" >> unlock-codes.txt; cat "$PWD"/*.[Hh][Tt][Mm][Ll] | grep -o '_midBackerTier=[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]' | grep -o '[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]' >> unlock-codes.txt
echo "---------------" >> unlock-codes.txt

# Printing ending.
echo "Enjoy it." >> unlock-codes.txt
echo 'This file created by "Mistress.Ayin" from "https://f95zone.to/".' >> unlock-codes.txt
echo `date` >> unlock-codes.txt

# Showing the codes:
cat "$PWD"/unlock-codes.txt; echo # Put an ENTER

# Pause the script.
read -p "Press Enter to continue..." -s

echo # Put an ENTER
