Skip to content

Commit

Permalink
new tips doc alrogrithm
Browse files Browse the repository at this point in the history
  • Loading branch information
c22dev committed Nov 28, 2023
1 parent e2fa547 commit 29b2599
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 7 deletions.
Binary file not shown.
31 changes: 25 additions & 6 deletions TipsGotTrolled/Classes/TS.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,32 @@ class TS {
return nil
}
}
func getTipsDocs(in directoryPath: String = "/var/mobile/Containers/Data/Application/") -> String? {
if let tipsPath = searchForTips(in: directoryPath) {
return tipsPath
} else {
UIApplication.shared.alert(title: "Error", body: "Tips Docs not found in the specified directory or its subdirectories. Is the app installed?")
return nil
func getTipsDoc(in directory: URL) -> URL? {
let fileManager = FileManager.default

do {
let contents = try fileManager.contentsOfDirectory(at: directory, includingPropertiesForKeys: nil, options: [])

for url in contents {
var isDirectory: ObjCBool = false
if fileManager.fileExists(atPath: url.path, isDirectory: &isDirectory) {
if isDirectory.boolValue {
if url.lastPathComponent == "Tips" {
print(url)
return url
} else {
if let subdirectoryResult = getTipsDoc(in: url) {
return subdirectoryResult
}
}
}
}
}
} catch {
print("Error reading directory: \(error)")
}

return nil
}

func isiOSVersionInRange() -> Bool {
Expand Down
2 changes: 1 addition & 1 deletion TipsGotTrolled/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ struct ContentView: View {
Button("Change Tips") {
do {
let documentsDirectoryURL = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first
let flagFilePath = "\(ts.getTipsDocs()!)/_trolled"
let flagFilePath = "\(ts.getTipsDoc(in: URL(fileURLWithPath:"/var/mobile/Containers/Data/Application/"))!)/_trolled"
if FileManager.default.fileExists(atPath: flagFilePath) {
UIApplication.shared.alert(title: "Please delete Tips app then reinstall it before proceeding", body: "⚠️ It looks like your Tips app have been tweaked. Please, delete it from Home Screen and reinstall it from the App Store. A reboot is recommended after reinstalling the Tips app.⚠️", withButton: false)
return
Expand Down

0 comments on commit 29b2599

Please sign in to comment.