From e08178a91600738ea8b122dccef5abdf90886d69 Mon Sep 17 00:00:00 2001 From: Jack Matthews Date: Sun, 12 Mar 2023 21:23:45 -0400 Subject: [PATCH] [Main] Execute patches --- Makefile | 3 +++ Resources/identity.js | 1 + Sources/VendettaTweak/Tweak.x.swift | 22 +++++++++++++++++++++- 3 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 Resources/identity.js diff --git a/Makefile b/Makefile index c5be4e8..6bcd160 100644 --- a/Makefile +++ b/Makefile @@ -9,4 +9,7 @@ VendettaTweak_FILES = $(shell find Sources/VendettaTweak -name '*.swift') $(shel VendettaTweak_SWIFTFLAGS = -ISources/VendettaTweakC/include VendettaTweak_CFLAGS = -fobjc-arc -ISources/VendettaTweakC/include +VendettaTweak_BUNDLE_NAME = VendettaPatches +VendettaTweak_BUNDLE_RESOURCE_DIRS = VendettaXposed/App/src/main/assets/js Resources + include $(THEOS_MAKE_PATH)/tweak.mk diff --git a/Resources/identity.js b/Resources/identity.js new file mode 100644 index 0000000..1fe91ca --- /dev/null +++ b/Resources/identity.js @@ -0,0 +1 @@ +this.__vendetta_loader={name:"VendettaTweak",features:{loaderConfig:false,devtools:{prop:"__vendetta_rdc",version:"4.27.1"}}}; \ No newline at end of file diff --git a/Sources/VendettaTweak/Tweak.x.swift b/Sources/VendettaTweak/Tweak.x.swift index 2c530a0..6b151a2 100644 --- a/Sources/VendettaTweak/Tweak.x.swift +++ b/Sources/VendettaTweak/Tweak.x.swift @@ -3,10 +3,30 @@ import VendettaTweakC import os let vendettaLog = OSLog(subsystem: Bundle.main.bundleIdentifier!, category: "vendetta") +let source = URL(string: "vendetta")! + +let vendettaPatchesBundlePath = + FileManager.default.fileExists( + atPath: "/Library/Application Support/VendettaTweak/VendettaPatches.bundle") + ? "/Library/Application Support/VendettaTweak/VendettaPatches.bundle" + : "\(Bundle.main.bundleURL.path)/VendettaPatches.bundle" class LoadHook: ClassHook { func executeApplicationScript(_ script: Data, url: URL, async: Bool) { os_log("executeApplicationScript called!", log: vendettaLog, type: .debug) - orig.executeApplicationScript(script, url: url, async: async) + + let vendettaPatchesBundle = Bundle(path: vendettaPatchesBundlePath)! + + os_log("Executing patches", log: vendettaLog, type: .info) + for patch in ["modules", "devtools", "identity"] { + if let patchPath = vendettaPatchesBundle.url(forResource: patch, withExtension: "js") { + let patchData = try! Data(contentsOf: patchPath) + os_log("Executing %{public}@ patch", log: vendettaLog, type: .debug, patch) + orig.executeApplicationScript(patchData, url: source, async: false) + } + } + + os_log("Executing original script", log: vendettaLog, type: .info) + orig.executeApplicationScript(script, url: url, async: false) } }