function CountTimeConsuming(mode) if mode == nil then os.exit(gg.alert('CountTimeConsuming mode == nil')) end if mode then TimeConsuming = os.clock() end if not mode then TimeConsuming = os.clock() - TimeConsuming end end Temp = {} file = {} function file.download(path, link) local write = function(FilePath, Content) local file = io.open(FilePath, "w") if file then file:write(Content) file:close() return true end return false end local CheckPath = function(path) local f, type_ = io.open(path, 'r') if type_ then if type_:find('EISDIR') then return 'dir' else return 'no' end else f:close() return 'file' end end if link == nil or link == '' or path == nil or path == '' then gg.alert('DownloadFile > link or path content == nil', 'return false') return false end local check = CheckPath(path) if gg.getFile() == path then gg.alert('DownloadFile > path == getFile()', 'return false') return false end if check == 'dir' then gg.alert('DownloadFile > path == dir', 'return false') return false end local content = gg.makeRequest(link).content if content == nil or content == '' then gg.alert('DownloadFile > link content == nil\n下载失败 链接:['..link..']读取失败', 'return false') return false end if not write(path, content) then gg.alert('文件保存失败\n'..path, 'return false') return false end end function file.exists(FilePath) local file = io.open(FilePath, "r") if file then file:close() return true end return false end function file.write(FilePath, Content) local file = io.open(FilePath, "w") if file then file:write(Content) file:close() return true end return false end function file.read(FilePath) local file = io.open(FilePath, "r") if file then local Content = file:read("*all") file:close() return Content end return nil end function file.read2(FilePath) local f = io.open(tostring(FilePath)) local data = '' if f ~= nil then data = f:read('*a') f:close() end return data end function file.check(FilePath) local f, type_ = io.open(FilePath, 'r') if type_ then if type_:find('EISDIR') then return 'dir' else return 'no' end else f:close() return 'file' end end function file.delete(FilePath) local result = os.remove(FilePath) if result then return true else return false end end function file.mkdir(FilePath) os.execute("mkdir "..FilePath) end function gg.alert2(title, content, button1, button2, button3) return gg.alert('['..title..']\n'..content, button1, button2, button3) end local print = function(content) print('['..os.date("%H:%M:%S")..']>'..content) end function FuHongGameGuardian_RunLog() local KJ = {} local ti = gg.getTargetInfo() if not ti then ti = {} end gg.x64 = ti.x64 == true gg.x32 = ti.x64 ~= true local x64 = ti.x64 == true local x32 = ti.x64 ~= true KJ['进程名称'] = tostring(ti['label']) KJ['Version'] = tostring(ti['versionName']) KJ['进程包名'] = tostring(ti['packageName']) --KJ['模块路径'] = tostring(ti['nativeLibraryDir']) KJ['PID'] = tostring(ti['pid']) KJ['UID'] = tostring(ti['uid']) KJ['x64'] = ti['x64'] == true --KJ['x32'] = ti['x32'] == true CountTimeConsuming(false) Content = 'FuHongGameGuardian '..FuHongGameGuardian_Version ..'\n云模块加载耗时:'..TimeConsuming..'seconds' ..'\nPackName:['.. gg.PACKAGE .. '] Version:['.. gg.VERSION .. ']\nRunTime:'.. os.date("%Y-%m-%d %H:%M:%S")..'\n' .. tostring(KJ) .. '\n==========\n' print(Content) end--run log function FuHongGameGuardian_StartFunc() if FuHongGameGuardian_FilePath == nil then FuHongGameGuardian_FilePath = '/storage/emulated/0/' end if file.exists(FuHongGameGuardianFilePath_Config) then FuHongGameGuardian_FilePath = file.read(FuHongGameGuardianFilePath_Config) else file.write(FuHongGameGuardianFilePath_Config, '/storage/emulated/0/') end Temp.Content = gg.prompt({'FuHongGameGuardian\n执行脚本页面 输入exit退出脚本 输入sx打开快捷脚本执行按钮\n'}, {FuHongGameGuardian_FilePath}, {'file'}) if not Temp.Content then if gg["Sx界面"] then return gg.toast('输入框被手动取消') else os.exit(print('输入框被手动取消')) end end--not if Temp.Content[1] == 'exit' then os.exit(print('接收到指令exit 退出')) end if Temp.Content[1] == 'sx' then print('接收到指令sx') if gg["Sx界面"] == nil then gg["Sx界面"] = true gg.toast("点击屏幕'Sx'打开执行脚本页") end--if nil while true do if gg["Sx界面"] then gg.showUiButton() if gg.isClickedUiButton() then FuHongGameGuardian_StartFunc() end end end--while end--if sx LoadFilePath = Temp.Content[1] Temp.Check = file.check(LoadFilePath) if Temp.Check == 'dir' then gg.alert2('出现错误', '目录路径:['..LoadFilePath..'] 为文件夹', '重试') return FuHongGameGuardian_StartFunc() end--dir if Temp.Check == 'no' then gg.alert2('出现错误', '目录路径:['..LoadFilePath..'] 读取失败', '重试') return FuHongGameGuardian_StartFunc() end--no if Temp.Check == 'file' then file.write(FuHongGameGuardianFilePath_Config, LoadFilePath) InjectContent = [[ local print = function(content) print('['..os.date("%H:%M:%S")..'] '..content) end ]] Temp.Content = file.read(LoadFilePath) CountTimeConsuming(true) local Code = InjectContent..Temp.Content load(Code)()--run CountTimeConsuming(false) print('脚本执行耗时:'..TimeConsuming..'seconds') end--file end--Start_Func CountTimeConsuming(true) FuHongGameGuardianFilePath_Config = '/storage/emulated/0/FuHong/..FHGG_LoadFilePath.json' FuHongGameGuardian_Version = 1.0 FuHongGameGuardian_RunLog() FuHongGameGuardian_StartFunc()