mirror of
https://github.com/ReVanced/revanced-patches.git
synced 2026-01-22 10:23:55 +00:00
Compare commits
8 Commits
v2.174.0-d
...
v2.174.0-d
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
769b1932d4 | ||
|
|
324d4b83d3 | ||
|
|
97822d6ee7 | ||
|
|
67674170da | ||
|
|
76711f0785 | ||
|
|
4178ca3be1 | ||
|
|
c681316ee1 | ||
|
|
b56844dc6b |
28
CHANGELOG.md
28
CHANGELOG.md
@@ -1,3 +1,31 @@
|
|||||||
|
# [2.174.0-dev.39](https://github.com/revanced/revanced-patches/compare/v2.174.0-dev.38...v2.174.0-dev.39) (2023-05-22)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* **reddit:** remove compatibility version constraints ([#2226](https://github.com/revanced/revanced-patches/issues/2226)) ([f1288e4](https://github.com/revanced/revanced-patches/commit/f1288e4bb8fb1b9f394d73fd814d97db8704b8e0))
|
||||||
|
|
||||||
|
# [2.174.0-dev.38](https://github.com/revanced/revanced-patches/compare/v2.174.0-dev.37...v2.174.0-dev.38) (2023-05-21)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* **trakt:** add `unlock-pro` patch ([#2210](https://github.com/revanced/revanced-patches/issues/2210)) ([1e8dcae](https://github.com/revanced/revanced-patches/commit/1e8dcae6f540455b8698703bbded5f52fd0c6300))
|
||||||
|
|
||||||
|
# [2.174.0-dev.37](https://github.com/revanced/revanced-patches/compare/v2.174.0-dev.36...v2.174.0-dev.37) (2023-05-21)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* **reddit:** add `sanitize-sharing-links` patch ([#2192](https://github.com/revanced/revanced-patches/issues/2192)) ([9593e4b](https://github.com/revanced/revanced-patches/commit/9593e4b5db604957545b4ab6747c82fb815ac08b))
|
||||||
|
|
||||||
|
# [2.174.0-dev.36](https://github.com/revanced/revanced-patches/compare/v2.174.0-dev.35...v2.174.0-dev.36) (2023-05-20)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **twitter:** correctly resolve to integrations methods ([c655416](https://github.com/revanced/revanced-patches/commit/c655416a91f0a32cfe82b1384f5958cace891833))
|
||||||
|
|
||||||
# [2.174.0-dev.35](https://github.com/revanced/revanced-patches/compare/v2.174.0-dev.34...v2.174.0-dev.35) (2023-05-19)
|
# [2.174.0-dev.35](https://github.com/revanced/revanced-patches/compare/v2.174.0-dev.34...v2.174.0-dev.35) (2023-05-19)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
29
README.md
29
README.md
@@ -141,6 +141,17 @@ The official ReVanced Patches.
|
|||||||
| `hide-views-stats` | Hides the view stats under tweets. | 9.71.0-release.0 |
|
| `hide-views-stats` | Hides the view stats under tweets. | 9.71.0-release.0 |
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
|
### [📦 `com.reddit.frontpage`](https://play.google.com/store/apps/details?id=com.reddit.frontpage)
|
||||||
|
<details>
|
||||||
|
|
||||||
|
| 💊 Patch | 📜 Description | 🏹 Target Version |
|
||||||
|
|:--------:|:--------------:|:-----------------:|
|
||||||
|
| `hide-ads` | Removes general ads from the Reddit frontpage and subreddits. | all |
|
||||||
|
| `hide-subreddit-banner` | Hides banner ads from comments on subreddits. | all |
|
||||||
|
| `premium-icon-reddit` | Unlocks premium Reddit app icons. | all |
|
||||||
|
| `sanitize-sharing-links` | Removes (tracking) query parameters from the URLs when sharing links. | all |
|
||||||
|
</details>
|
||||||
|
|
||||||
### [📦 `com.spotify.music`](https://play.google.com/store/apps/details?id=com.spotify.music)
|
### [📦 `com.spotify.music`](https://play.google.com/store/apps/details?id=com.spotify.music)
|
||||||
<details>
|
<details>
|
||||||
|
|
||||||
@@ -161,16 +172,6 @@ The official ReVanced Patches.
|
|||||||
| `hide-inbox-ads` | Hides ads in inbox. | all |
|
| `hide-inbox-ads` | Hides ads in inbox. | all |
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
### [📦 `com.reddit.frontpage`](https://play.google.com/store/apps/details?id=com.reddit.frontpage)
|
|
||||||
<details>
|
|
||||||
|
|
||||||
| 💊 Patch | 📜 Description | 🏹 Target Version |
|
|
||||||
|:--------:|:--------------:|:-----------------:|
|
|
||||||
| `hide-ads` | Removes general ads from the Reddit frontpage and subreddits. | 2023.12.0 |
|
|
||||||
| `hide-subreddit-banner` | Hides banner ads from comments on subreddits. | 2023.12.0 |
|
|
||||||
| `premium-icon-reddit` | Unlocks premium Reddit app icons. | all |
|
|
||||||
</details>
|
|
||||||
|
|
||||||
### [📦 `at.gv.bmf.bmf2go`](https://play.google.com/store/apps/details?id=at.gv.bmf.bmf2go)
|
### [📦 `at.gv.bmf.bmf2go`](https://play.google.com/store/apps/details?id=at.gv.bmf.bmf2go)
|
||||||
<details>
|
<details>
|
||||||
|
|
||||||
@@ -341,6 +342,14 @@ The official ReVanced Patches.
|
|||||||
| `unlock-pro` | Unlocks all pro features. | all |
|
| `unlock-pro` | Unlocks all pro features. | all |
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
|
### [📦 `tv.trakt.trakt`](https://play.google.com/store/apps/details?id=tv.trakt.trakt)
|
||||||
|
<details>
|
||||||
|
|
||||||
|
| 💊 Patch | 📜 Description | 🏹 Target Version |
|
||||||
|
|:--------:|:--------------:|:-----------------:|
|
||||||
|
| `unlock-pro` | Unlocks pro features. | all |
|
||||||
|
</details>
|
||||||
|
|
||||||
### [📦 `co.windyapp.android`](https://play.google.com/store/apps/details?id=co.windyapp.android)
|
### [📦 `co.windyapp.android`](https://play.google.com/store/apps/details?id=co.windyapp.android)
|
||||||
<details>
|
<details>
|
||||||
|
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
kotlin.code.style = official
|
kotlin.code.style = official
|
||||||
version = 2.174.0-dev.35
|
version = 2.174.0-dev.39
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -5,18 +5,7 @@ import app.revanced.patcher.annotation.Package
|
|||||||
|
|
||||||
@Compatibility(
|
@Compatibility(
|
||||||
[Package(
|
[Package(
|
||||||
"com.reddit.frontpage", arrayOf(
|
"com.reddit.frontpage"
|
||||||
"2023.05.0",
|
|
||||||
"2023.06.0",
|
|
||||||
"2023.07.0",
|
|
||||||
"2023.07.1",
|
|
||||||
"2023.08.0",
|
|
||||||
"2023.09.0",
|
|
||||||
"2023.09.1",
|
|
||||||
"2023.10.0",
|
|
||||||
"2023.11.0",
|
|
||||||
"2023.12.0"
|
|
||||||
)
|
|
||||||
)]
|
)]
|
||||||
)
|
)
|
||||||
@Target(AnnotationTarget.CLASS)
|
@Target(AnnotationTarget.CLASS)
|
||||||
|
|||||||
@@ -5,20 +5,7 @@ import app.revanced.patcher.annotation.Package
|
|||||||
|
|
||||||
@Compatibility(
|
@Compatibility(
|
||||||
[Package(
|
[Package(
|
||||||
"com.reddit.frontpage", arrayOf(
|
"com.reddit.frontpage"
|
||||||
"2021.45.0",
|
|
||||||
"2022.43.0",
|
|
||||||
"2023.05.0",
|
|
||||||
"2023.06.0",
|
|
||||||
"2023.07.0",
|
|
||||||
"2023.07.1",
|
|
||||||
"2023.08.0",
|
|
||||||
"2023.09.0",
|
|
||||||
"2023.09.1",
|
|
||||||
"2023.10.0",
|
|
||||||
"2023.11.0",
|
|
||||||
"2023.12.0"
|
|
||||||
)
|
|
||||||
)]
|
)]
|
||||||
)
|
)
|
||||||
@Target(AnnotationTarget.CLASS)
|
@Target(AnnotationTarget.CLASS)
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package app.revanced.patches.reddit.misc.tracking.url.annotations
|
||||||
|
|
||||||
|
import app.revanced.patcher.annotation.Compatibility
|
||||||
|
import app.revanced.patcher.annotation.Package
|
||||||
|
|
||||||
|
@Compatibility(
|
||||||
|
[Package(
|
||||||
|
"com.reddit.frontpage"
|
||||||
|
)]
|
||||||
|
)
|
||||||
|
@Target(AnnotationTarget.CLASS)
|
||||||
|
internal annotation class SanitizeUrlQueryCompatibility
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package app.revanced.patches.reddit.misc.tracking.url.fingerprints
|
||||||
|
|
||||||
|
import app.revanced.patcher.extensions.or
|
||||||
|
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||||
|
import org.jf.dexlib2.AccessFlags
|
||||||
|
import org.jf.dexlib2.Opcode
|
||||||
|
|
||||||
|
object ShareLinkFactoryFingerprint : MethodFingerprint(
|
||||||
|
returnType = "L",
|
||||||
|
access = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||||
|
opcodes = listOf(
|
||||||
|
Opcode.CONST_STRING,
|
||||||
|
Opcode.CONST_STRING,
|
||||||
|
Opcode.INVOKE_DIRECT,
|
||||||
|
Opcode.APUT_OBJECT,
|
||||||
|
Opcode.INVOKE_STATIC,
|
||||||
|
Opcode.MOVE_RESULT_OBJECT,
|
||||||
|
Opcode.INVOKE_STATIC, // Returns the URL.
|
||||||
|
Opcode.MOVE_RESULT_OBJECT
|
||||||
|
),
|
||||||
|
customFingerprint = { methodDef, _ -> methodDef.definingClass.endsWith("ShareLinkFactory;") }
|
||||||
|
)
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
package app.revanced.patches.reddit.misc.tracking.url.patch
|
||||||
|
|
||||||
|
import app.revanced.extensions.toErrorResult
|
||||||
|
import app.revanced.patcher.annotation.Description
|
||||||
|
import app.revanced.patcher.annotation.Name
|
||||||
|
import app.revanced.patcher.annotation.Version
|
||||||
|
import app.revanced.patcher.data.BytecodeContext
|
||||||
|
import app.revanced.patcher.extensions.addInstructions
|
||||||
|
import app.revanced.patcher.extensions.instruction
|
||||||
|
import app.revanced.patcher.patch.BytecodePatch
|
||||||
|
import app.revanced.patcher.patch.PatchResult
|
||||||
|
import app.revanced.patcher.patch.PatchResultSuccess
|
||||||
|
import app.revanced.patcher.patch.annotations.Patch
|
||||||
|
import app.revanced.patcher.patch.annotations.RequiresIntegrations
|
||||||
|
import app.revanced.patches.reddit.misc.tracking.url.annotations.SanitizeUrlQueryCompatibility
|
||||||
|
import app.revanced.patches.reddit.misc.tracking.url.fingerprints.ShareLinkFactoryFingerprint
|
||||||
|
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
|
||||||
|
|
||||||
|
@Patch
|
||||||
|
@Name("sanitize-sharing-links")
|
||||||
|
@Description("Removes (tracking) query parameters from the URLs when sharing links.")
|
||||||
|
@SanitizeUrlQueryCompatibility
|
||||||
|
@Version("0.0.1")
|
||||||
|
@RequiresIntegrations
|
||||||
|
class SanitizeUrlQueryPatch : BytecodePatch(
|
||||||
|
listOf(ShareLinkFactoryFingerprint)
|
||||||
|
) {
|
||||||
|
override fun execute(context: BytecodeContext): PatchResult {
|
||||||
|
ShareLinkFactoryFingerprint.result?.let { result ->
|
||||||
|
result.mutableMethod.apply {
|
||||||
|
val insertIndex = result.scanResult.patternScanResult!!.endIndex + 1
|
||||||
|
val urlRegister = instruction<OneRegisterInstruction>(insertIndex - 1).registerA
|
||||||
|
|
||||||
|
addInstructions(
|
||||||
|
insertIndex,
|
||||||
|
"""
|
||||||
|
invoke-static {v$urlRegister}, $SANITIZE_METHOD_DESCRIPTOR
|
||||||
|
move-result-object v$urlRegister
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
}
|
||||||
|
} ?: return ShareLinkFactoryFingerprint.toErrorResult()
|
||||||
|
|
||||||
|
return PatchResultSuccess()
|
||||||
|
}
|
||||||
|
|
||||||
|
private companion object {
|
||||||
|
private const val SANITIZE_METHOD_DESCRIPTOR =
|
||||||
|
"Lapp/revanced/reddit/patches/SanitizeUrlQueryPatch;" +
|
||||||
|
"->stripQueryParameters(Ljava/lang/String;)Ljava/lang/String;"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
package app.revanced.patches.trakt.annotations
|
||||||
|
|
||||||
|
import app.revanced.patcher.annotation.Compatibility
|
||||||
|
import app.revanced.patcher.annotation.Package
|
||||||
|
|
||||||
|
@Compatibility([Package("tv.trakt.trakt")])
|
||||||
|
@Target(AnnotationTarget.CLASS)
|
||||||
|
internal annotation class UnlockProCompatibility
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
package app.revanced.patches.trakt.fingerprints
|
||||||
|
|
||||||
|
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||||
|
|
||||||
|
object IsVIPEPFingerprint : MethodFingerprint(
|
||||||
|
customFingerprint = custom@{ methodDef, _ ->
|
||||||
|
if (!methodDef.definingClass.endsWith("RealmUserSettings;")) return@custom false
|
||||||
|
|
||||||
|
methodDef.name == "isVIPEP"
|
||||||
|
}
|
||||||
|
)
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
package app.revanced.patches.trakt.fingerprints
|
||||||
|
|
||||||
|
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||||
|
|
||||||
|
object IsVIPFingerprint : MethodFingerprint(
|
||||||
|
customFingerprint = custom@{ methodDef, _ ->
|
||||||
|
if (!methodDef.definingClass.endsWith("RealmUserSettings;")) return@custom false
|
||||||
|
|
||||||
|
methodDef.name == "isVIP"
|
||||||
|
}
|
||||||
|
)
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package app.revanced.patches.trakt.fingerprints
|
||||||
|
|
||||||
|
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||||
|
|
||||||
|
object RealmUserSettingsFingerprint : MethodFingerprint(
|
||||||
|
customFingerprint = { methodDef, _ ->
|
||||||
|
methodDef.definingClass.endsWith("RealmUserSettings;")
|
||||||
|
}
|
||||||
|
)
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
package app.revanced.patches.trakt.patch
|
||||||
|
|
||||||
|
import app.revanced.extensions.toErrorResult
|
||||||
|
import app.revanced.patcher.annotation.Description
|
||||||
|
import app.revanced.patcher.annotation.Name
|
||||||
|
import app.revanced.patcher.annotation.Version
|
||||||
|
import app.revanced.patcher.data.BytecodeContext
|
||||||
|
import app.revanced.patcher.extensions.addInstructions
|
||||||
|
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve
|
||||||
|
import app.revanced.patcher.patch.BytecodePatch
|
||||||
|
import app.revanced.patcher.patch.PatchResult
|
||||||
|
import app.revanced.patcher.patch.PatchResultSuccess
|
||||||
|
import app.revanced.patcher.patch.annotations.Patch
|
||||||
|
import app.revanced.patches.trakt.annotations.UnlockProCompatibility
|
||||||
|
import app.revanced.patches.trakt.fingerprints.IsVIPEPFingerprint
|
||||||
|
import app.revanced.patches.trakt.fingerprints.IsVIPFingerprint
|
||||||
|
import app.revanced.patches.trakt.fingerprints.RealmUserSettingsFingerprint
|
||||||
|
|
||||||
|
@Patch
|
||||||
|
@Name("unlock-pro")
|
||||||
|
@Description("Unlocks pro features.")
|
||||||
|
@UnlockProCompatibility
|
||||||
|
@Version("0.0.1")
|
||||||
|
class UnlockProPatch : BytecodePatch(
|
||||||
|
listOf(RealmUserSettingsFingerprint)
|
||||||
|
) {
|
||||||
|
override fun execute(context: BytecodeContext): PatchResult {
|
||||||
|
RealmUserSettingsFingerprint.result?.classDef?.let { realUserSettingsClass ->
|
||||||
|
arrayOf(IsVIPFingerprint, IsVIPEPFingerprint).onEach { fingerprint ->
|
||||||
|
// Resolve both fingerprints on the same class.
|
||||||
|
if (!fingerprint.resolve(context, realUserSettingsClass))
|
||||||
|
throw fingerprint.toErrorResult()
|
||||||
|
}.forEach { fingerprint ->
|
||||||
|
// Return true for both VIP check methods.
|
||||||
|
fingerprint.result?.mutableMethod?.addInstructions(0, RETURN_TRUE_INSTRUCTIONS)
|
||||||
|
?: return fingerprint.toErrorResult()
|
||||||
|
}
|
||||||
|
} ?: return RealmUserSettingsFingerprint.toErrorResult()
|
||||||
|
|
||||||
|
return PatchResultSuccess()
|
||||||
|
}
|
||||||
|
|
||||||
|
private companion object {
|
||||||
|
const val RETURN_TRUE_INSTRUCTIONS =
|
||||||
|
"""
|
||||||
|
const/4 v0, 0x1
|
||||||
|
invoke-static {v0}, Ljava/lang/Boolean;->valueOf(Z)Ljava/lang/Boolean;
|
||||||
|
move-result-object v1
|
||||||
|
return-object v1
|
||||||
|
"""
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,5 +5,9 @@ import org.jf.dexlib2.Opcode
|
|||||||
|
|
||||||
object JsonHookPatchFingerprint : MethodFingerprint(
|
object JsonHookPatchFingerprint : MethodFingerprint(
|
||||||
customFingerprint = { methodDef, _ -> methodDef.name == "<clinit>" },
|
customFingerprint = { methodDef, _ -> methodDef.name == "<clinit>" },
|
||||||
opcodes = listOf(Opcode.IGET_OBJECT)
|
opcodes = listOf(
|
||||||
|
Opcode.INVOKE_INTERFACE, // Add dummy hook to hooks list.
|
||||||
|
// Add hooks to the hooks list.
|
||||||
|
Opcode.INVOKE_STATIC // Call buildList.
|
||||||
|
)
|
||||||
)
|
)
|
||||||
@@ -5,13 +5,18 @@ import app.revanced.patcher.annotation.Name
|
|||||||
import app.revanced.patcher.annotation.Version
|
import app.revanced.patcher.annotation.Version
|
||||||
import app.revanced.patcher.data.BytecodeContext
|
import app.revanced.patcher.data.BytecodeContext
|
||||||
import app.revanced.patcher.extensions.addInstructions
|
import app.revanced.patcher.extensions.addInstructions
|
||||||
|
import app.revanced.patcher.extensions.removeInstructions
|
||||||
|
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve
|
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve
|
||||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprintResult
|
import app.revanced.patcher.patch.BytecodePatch
|
||||||
import app.revanced.patcher.patch.*
|
import app.revanced.patcher.patch.PatchResult
|
||||||
|
import app.revanced.patcher.patch.PatchResultError
|
||||||
|
import app.revanced.patcher.patch.PatchResultSuccess
|
||||||
import app.revanced.patcher.patch.annotations.RequiresIntegrations
|
import app.revanced.patcher.patch.annotations.RequiresIntegrations
|
||||||
import app.revanced.patches.twitter.misc.hook.json.fingerprints.JsonHookPatchFingerprint
|
import app.revanced.patches.twitter.misc.hook.json.fingerprints.JsonHookPatchFingerprint
|
||||||
import app.revanced.patches.twitter.misc.hook.json.fingerprints.JsonInputStreamFingerprint
|
import app.revanced.patches.twitter.misc.hook.json.fingerprints.JsonInputStreamFingerprint
|
||||||
import app.revanced.patches.twitter.misc.hook.json.fingerprints.LoganSquareFingerprint
|
import app.revanced.patches.twitter.misc.hook.json.fingerprints.LoganSquareFingerprint
|
||||||
|
import java.io.Closeable
|
||||||
import java.io.InvalidClassException
|
import java.io.InvalidClassException
|
||||||
|
|
||||||
@Name("json-hook")
|
@Name("json-hook")
|
||||||
@@ -20,16 +25,16 @@ import java.io.InvalidClassException
|
|||||||
@RequiresIntegrations
|
@RequiresIntegrations
|
||||||
class JsonHookPatch : BytecodePatch(
|
class JsonHookPatch : BytecodePatch(
|
||||||
listOf(LoganSquareFingerprint)
|
listOf(LoganSquareFingerprint)
|
||||||
) {
|
), Closeable {
|
||||||
override fun execute(context: BytecodeContext): PatchResult {
|
override fun execute(context: BytecodeContext): PatchResult {
|
||||||
// Make sure the integrations are present.
|
JsonHookPatchFingerprint.also {
|
||||||
val jsonHookPatch = context.findClass { it.type == JSON_HOOK_PATCH_CLASS_DESCRIPTOR }
|
// Make sure the integrations are present.
|
||||||
?: return PatchResultError("Could not find integrations.")
|
val jsonHookPatch = context.findClass { classDef -> classDef.type == JSON_HOOK_PATCH_CLASS_DESCRIPTOR }
|
||||||
|
?: throw PatchResultError("Could not find integrations.")
|
||||||
|
|
||||||
// Allow patch to inject hooks into the patches integrations.
|
if (!it.resolve(context, jsonHookPatch.immutableClass))
|
||||||
jsonHookPatchFingerprintResult = JsonHookPatchFingerprint.also {
|
throw PatchResultError("Unexpected integrations.")
|
||||||
it.resolve(context, jsonHookPatch.immutableClass)
|
}.let { hooks = JsonHookPatchHook(it) }
|
||||||
}.result ?: return PatchResultError("Unexpected integrations.")
|
|
||||||
|
|
||||||
// Conveniently find the type to hook a method in, via a named field.
|
// Conveniently find the type to hook a method in, via a named field.
|
||||||
val jsonFactory = LoganSquareFingerprint.result
|
val jsonFactory = LoganSquareFingerprint.result
|
||||||
@@ -64,30 +69,10 @@ class JsonHookPatch : BytecodePatch(
|
|||||||
*
|
*
|
||||||
* @param context The [BytecodeContext] of the current patch.
|
* @param context The [BytecodeContext] of the current patch.
|
||||||
* @param descriptor The class descriptor of the hook.
|
* @param descriptor The class descriptor of the hook.
|
||||||
|
* @throws ClassNotFoundException If the class could not be found.
|
||||||
*/
|
*/
|
||||||
internal class Hook(context: BytecodeContext, private val descriptor: String) {
|
internal class Hook(context: BytecodeContext, internal val descriptor: String) {
|
||||||
private var added = false
|
internal var added = false
|
||||||
|
|
||||||
/**
|
|
||||||
* Add the hook.
|
|
||||||
*/
|
|
||||||
internal fun add() {
|
|
||||||
if (added) return
|
|
||||||
|
|
||||||
jsonHookPatchFingerprintResult.apply {
|
|
||||||
mutableMethod.apply {
|
|
||||||
addInstructions(
|
|
||||||
scanResult.patternScanResult!!.startIndex,
|
|
||||||
"""
|
|
||||||
sget-object v1, $descriptor->INSTANCE:$descriptor
|
|
||||||
invoke-virtual {v0, v1}, Lkotlin/collections/builders/ListBuilder;->add(Ljava/lang/Object;)Z
|
|
||||||
"""
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
added = true
|
|
||||||
}
|
|
||||||
|
|
||||||
init {
|
init {
|
||||||
context.findClass { it.type == descriptor }?.let {
|
context.findClass { it.type == descriptor }?.let {
|
||||||
@@ -102,15 +87,67 @@ class JsonHookPatch : BytecodePatch(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private companion object {
|
/**
|
||||||
const val JSON_HOOK_CLASS_NAMESPACE = "app/revanced/twitter/patches/hook/json"
|
* A hook for the [JsonHookPatch].
|
||||||
|
*
|
||||||
|
* @param jsonHookPatchFingerprint The [JsonHookPatchFingerprint] to hook.
|
||||||
|
*/
|
||||||
|
internal class JsonHookPatchHook(jsonHookPatchFingerprint: MethodFingerprint): Closeable {
|
||||||
|
private val jsonHookPatchFingerprintResult = jsonHookPatchFingerprint.result!!
|
||||||
|
private val jsonHookPatchIndex = jsonHookPatchFingerprintResult.scanResult.patternScanResult!!.endIndex
|
||||||
|
|
||||||
const val JSON_HOOK_PATCH_CLASS_DESCRIPTOR = "L$JSON_HOOK_CLASS_NAMESPACE/JsonHookPatch;"
|
/**
|
||||||
|
* Add a hook to the [JsonHookPatch].
|
||||||
|
* Will not add the hook if it's already added.
|
||||||
|
*
|
||||||
|
* @param hook The [Hook] to add.
|
||||||
|
*/
|
||||||
|
fun addHook(hook: Hook) {
|
||||||
|
if (hook.added) return
|
||||||
|
|
||||||
const val BASE_PATCH_CLASS_NAME = "BaseJsonHook"
|
jsonHookPatchFingerprintResult.mutableMethod.apply {
|
||||||
|
// Insert hooks right before calling buildList.
|
||||||
|
val insertIndex = jsonHookPatchIndex
|
||||||
|
|
||||||
const val JSON_HOOK_CLASS_DESCRIPTOR = "L$JSON_HOOK_CLASS_NAMESPACE/$BASE_PATCH_CLASS_NAME;"
|
addInstructions(
|
||||||
|
insertIndex,
|
||||||
|
"""
|
||||||
|
sget-object v1, ${hook.descriptor}->INSTANCE:${hook.descriptor}
|
||||||
|
invoke-interface {v0, v1}, Ljava/util/List;->add(Ljava/lang/Object;)Z
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
private lateinit var jsonHookPatchFingerprintResult: MethodFingerprintResult
|
hook.added = true
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun close() {
|
||||||
|
// Remove hooks.add(dummyHook).
|
||||||
|
jsonHookPatchFingerprintResult.mutableMethod.apply {
|
||||||
|
val addDummyHookIndex = jsonHookPatchIndex - 2
|
||||||
|
|
||||||
|
removeInstructions(addDummyHookIndex, 2)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun close() = hooks.close()
|
||||||
|
|
||||||
|
internal companion object {
|
||||||
|
private const val JSON_HOOK_CLASS_NAMESPACE = "app/revanced/twitter/patches/hook/json"
|
||||||
|
|
||||||
|
private const val JSON_HOOK_PATCH_CLASS_DESCRIPTOR = "L$JSON_HOOK_CLASS_NAMESPACE/JsonHookPatch;"
|
||||||
|
|
||||||
|
private const val BASE_PATCH_CLASS_NAME = "BaseJsonHook"
|
||||||
|
|
||||||
|
private const val JSON_HOOK_CLASS_DESCRIPTOR = "L$JSON_HOOK_CLASS_NAMESPACE/$BASE_PATCH_CLASS_NAME;"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The [JsonHookPatchHook] of the [JsonHookPatch].
|
||||||
|
*
|
||||||
|
* @see JsonHookPatchHook
|
||||||
|
*/
|
||||||
|
internal lateinit var hooks: JsonHookPatchHook
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -4,13 +4,13 @@ import app.revanced.patcher.data.BytecodeContext
|
|||||||
import app.revanced.patcher.patch.BytecodePatch
|
import app.revanced.patcher.patch.BytecodePatch
|
||||||
import app.revanced.patcher.patch.PatchResultError
|
import app.revanced.patcher.patch.PatchResultError
|
||||||
import app.revanced.patcher.patch.PatchResultSuccess
|
import app.revanced.patcher.patch.PatchResultSuccess
|
||||||
import app.revanced.patcher.patch.annotations.DependsOn
|
|
||||||
import app.revanced.patches.twitter.misc.hook.json.patch.JsonHookPatch
|
import app.revanced.patches.twitter.misc.hook.json.patch.JsonHookPatch
|
||||||
|
|
||||||
@DependsOn([JsonHookPatch::class])
|
|
||||||
abstract class BaseHookPatchPatch(private val hookClassDescriptor: String) : BytecodePatch() {
|
abstract class BaseHookPatchPatch(private val hookClassDescriptor: String) : BytecodePatch() {
|
||||||
override fun execute(context: BytecodeContext) = try {
|
override fun execute(context: BytecodeContext) = try {
|
||||||
PatchResultSuccess().also { JsonHookPatch.Hook(context, hookClassDescriptor).add() }
|
JsonHookPatch.hooks.addHook(JsonHookPatch.Hook(context, hookClassDescriptor))
|
||||||
|
|
||||||
|
PatchResultSuccess()
|
||||||
} catch (ex: Exception) {
|
} catch (ex: Exception) {
|
||||||
PatchResultError(ex)
|
PatchResultError(ex)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,8 +15,4 @@ import app.revanced.patches.twitter.misc.hook.patch.ads.annotations.HideAdsCompa
|
|||||||
@Description("Hides ads.")
|
@Description("Hides ads.")
|
||||||
@HideAdsCompatibility
|
@HideAdsCompatibility
|
||||||
@Version("0.0.1")
|
@Version("0.0.1")
|
||||||
class HideAdsPatch : BaseHookPatchPatch(HOOK_CLASS_DESCRIPTOR) {
|
class HideAdsPatch : BaseHookPatchPatch("Lapp/revanced/twitter/patches/hook/patch/ads/AdsHook;")
|
||||||
private companion object {
|
|
||||||
const val HOOK_CLASS_DESCRIPTOR = "Lapp/revanced/twitter/patches/hook/patch/ads/AdsHook;"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -15,9 +15,6 @@ import app.revanced.patches.twitter.misc.hook.patch.recommendation.annotations.H
|
|||||||
@Description("Hides recommended users.")
|
@Description("Hides recommended users.")
|
||||||
@HideRecommendedUsersCompatibility
|
@HideRecommendedUsersCompatibility
|
||||||
@Version("0.0.1")
|
@Version("0.0.1")
|
||||||
class HideRecommendedUsersPatch : BaseHookPatchPatch(HOOK_CLASS_DESCRIPTOR) {
|
class HideRecommendedUsersPatch : BaseHookPatchPatch(
|
||||||
private companion object {
|
"Lapp/revanced/twitter/patches/hook/patch/recommendation/RecommendedUsersHook;"
|
||||||
const val HOOK_CLASS_DESCRIPTOR =
|
)
|
||||||
"Lapp/revanced/twitter/patches/hook/patch/recommendation/RecommendedUsersHook;"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user