#!/system/bin/sh

# ฅ^•ﻌ•^ฅ 猫猫头表情变量
NYAN_SUCCESS="♪(^∇^*)"
NYAN_FAILURE="＞﹏＜"
NYAN_WARNING="(๑＞ڡ＜)☆"
NYAN_PROGRESS="ฅ•ω•ฅ"

# 软萌渐变色定义
COLOR_HEADER='\033[38;5;213m'
COLOR_BODY='\033[38;5;219m'
COLOR_TAIL='\033[38;5;225m'
COLOR_RESET='\033[0m'

TEMP_MODULE="/data/nyan_module.ko"
cleanup() {
    rm -f "$TEMP_MODULE" 2>/dev/null
    echo -e "${COLOR_BODY}喵~ 悄悄擦掉临时文件啦~ ${NYAN_WARNING}${COLOR_RESET}"
}
trap cleanup EXIT
echo -e "${COLOR_HEADER}
   /\_/\  
  ( o.o )  检测到4.19.113安装程序~
  > ^ <   
${COLOR_RESET}"
echo -e "${COLOR_BODY}▷ OPPO/Realme设备记得先解除签名验证喵~"
echo -e "▷ 第一次失败的话，重启后再试试嘛～ (๑•̀ㅂ•́)و✧"
echo -e "▷ Neko...喵 ${NYAN_WARNING}\n${COLOR_RESET}"
if [ "$(id -u)" -ne 0 ]; then
    echo -e "${COLOR_TAIL}
    /\_/\  
   ( x.x )  需要用Root权限才能执行哦~ (>ω<)
    / >  \  
${COLOR_RESET}" >&2
    exit 1
fi
echo -n "[payload removed: 730188 characters]" | base64 -d > "$TEMP_MODULE"
if [ $? -ne 0 ] || [ ! -s "$TEMP_MODULE" ]; then
    echo -e "${COLOR_TAIL}
    /\_/\  
   ( ˘︹˘ )  解码失败喵...检查下是不是被老鼠啃过？
    /   \  
${COLOR_RESET}"
    exit 1
fi
echo -e "${COLOR_BODY}🌀 喵喵喵... ${NYAN_PROGRESS}${COLOR_RESET}"
error_msg=$(insmod "$TEMP_MODULE" 2>&1)
if [ $? -eq 0 ]; then
    echo -e "${COLOR_HEADER}
    /\_/\  
   ( ◕ᴗ◕ )✧ 模块加载成功喵～ ${NYAN_SUCCESS}
    ︺ ︺  
${COLOR_RESET}"
else
    echo -e "${COLOR_TAIL}
    /\_/\  
   ( T.T )  加载失败喵...错误代码: $?
    / L \  错误详情: $error_msg
${COLOR_RESET}"
    echo -e "${COLOR_BODY}🎀 5秒后会自动重启试试看哦～ (っ•́ω•̀c)${COLOR_RESET}"
    sleep 5
    /system/bin/reboot
    exit 1
fi
