mirror of
https://github.com/ReVanced/revanced-patches.git
synced 2026-01-16 07:43:56 +00:00
Compare commits
14 Commits
v2.163.0-d
...
v2.163.0-d
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3da4a85f63 | ||
|
|
1241701ac7 | ||
|
|
154dcf6cb4 | ||
|
|
b110348af0 | ||
|
|
3153f73ceb | ||
|
|
5ca5d4c64a | ||
|
|
5a7ce48847 | ||
|
|
dfccd1cc0a | ||
|
|
0606f3a9be | ||
|
|
b2e4691e88 | ||
|
|
6d20931db7 | ||
|
|
72d8316ed2 | ||
|
|
531d4913ab | ||
|
|
98df006527 |
@@ -39,7 +39,7 @@
|
||||
[
|
||||
"@saithodev/semantic-release-backmerge",
|
||||
{
|
||||
backmergeBranches: ["dev"],
|
||||
backmergeBranches: [{"from": "dev", "to": "main"}],
|
||||
clearWorkspace: true
|
||||
}
|
||||
]
|
||||
|
||||
33
CHANGELOG.md
33
CHANGELOG.md
@@ -1,3 +1,36 @@
|
||||
# [2.163.0-dev.6](https://github.com/revanced/revanced-patches/compare/v2.163.0-dev.5...v2.163.0-dev.6) (2023-02-22)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **photomath:** `unlock-plus` patch ([#1633](https://github.com/revanced/revanced-patches/issues/1633)) ([a7f5330](https://github.com/revanced/revanced-patches/commit/a7f5330e602c36492e329000dc9f0a1eda218770))
|
||||
|
||||
# [2.163.0-dev.5](https://github.com/revanced/revanced-patches/compare/v2.163.0-dev.4...v2.163.0-dev.5) (2023-02-22)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* use correct fingerprint ([84fe9c3](https://github.com/revanced/revanced-patches/commit/84fe9c36461586f25ace146e0e29597e3dfc99ca))
|
||||
* **youtube/hide-time:** use correct integrations class ([539ccf4](https://github.com/revanced/revanced-patches/commit/539ccf43a884ab3ff812884279aa75f42ba872d5))
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* use better patch descriptions ([931aa0f](https://github.com/revanced/revanced-patches/commit/931aa0fba631d1740986131219eff94c4c1b2306))
|
||||
|
||||
# [2.163.0-dev.4](https://github.com/revanced/revanced-patches/compare/v2.163.0-dev.3...v2.163.0-dev.4) (2023-02-22)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **twitter:** make `hide-promoted-ads` patch compatible with any version ([3dbc5ff](https://github.com/revanced/revanced-patches/commit/3dbc5ff2722559211232999ae29e7fabafe3b857))
|
||||
* **youtube/open-links-directly:** reference correct integrations method ([e14893e](https://github.com/revanced/revanced-patches/commit/e14893ec89d002287123196396946fff557b7ef4))
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **twitter:** `hide-recommended-users` patch ([e8c9a91](https://github.com/revanced/revanced-patches/commit/e8c9a91a92fafcc79ce521f62c3865827df55d0f))
|
||||
|
||||
# [2.163.0-dev.3](https://github.com/revanced/revanced-patches/compare/v2.163.0-dev.2...v2.163.0-dev.3) (2023-02-20)
|
||||
|
||||
|
||||
|
||||
13
README.md
13
README.md
@@ -36,7 +36,7 @@ The official Patch bundle provided by ReVanced and the community.
|
||||
| `hide-crowdfunding-box` | Hides the crowdfunding box between the player and video description. | 18.03.36 |
|
||||
| `hide-email-address` | Hides the email address in the account switcher. | 18.03.36 |
|
||||
| `hide-endscreen-cards` | Hides the suggested video cards at the end of a video in fullscreen. | 18.03.36 |
|
||||
| `hide-info-cards` | Hides info-cards in videos. | 18.03.36 |
|
||||
| `hide-info-cards` | Hides info cards in videos. | 18.03.36 |
|
||||
| `hide-my-mix` | Hides mix playlists. | 18.03.36 |
|
||||
| `hide-player-buttons` | Adds the option to hide video player previous and next buttons. | all |
|
||||
| `hide-seekbar` | Hides the seekbar. | 18.03.36 |
|
||||
@@ -132,9 +132,10 @@ The official Patch bundle provided by ReVanced and the community.
|
||||
| 💊 Patch | 📜 Description | 🏹 Target Version |
|
||||
|:--------:|:--------------:|:-----------------:|
|
||||
| `dynamic-color` | Replaces the default Twitter Blue with the users Material You palette. | all |
|
||||
| `hide-ads` | Hides ads. | all |
|
||||
| `hide-recommended-users` | Hides recommended users. | all |
|
||||
| `hide-views-stats` | Hides the view stats under tweets. | 9.71.0-release.0 |
|
||||
| `monochrome-icon` | Adds a monochrome icon. | all |
|
||||
| `timeline-ads` | Removes ads from the Twitter timeline. Might require clearing app data to remove already cached ads. | 9.71.0-release.0 |
|
||||
</details>
|
||||
|
||||
### [📦 `com.spotify.music`](https://play.google.com/store/apps/details?id=com.spotify.music)
|
||||
@@ -263,6 +264,14 @@ The official Patch bundle provided by ReVanced and the community.
|
||||
| `unlock-paid-widgets` | Unlocks paid widgets of the app | all |
|
||||
</details>
|
||||
|
||||
### [📦 `com.microblink.photomath`](https://play.google.com/store/apps/details?id=com.microblink.photomath)
|
||||
<details>
|
||||
|
||||
| 💊 Patch | 📜 Description | 🏹 Target Version |
|
||||
|:--------:|:--------------:|:-----------------:|
|
||||
| `unlock-plus` | Unlocks plus features. | all |
|
||||
</details>
|
||||
|
||||
### [📦 `io.yuka.android`](https://play.google.com/store/apps/details?id=io.yuka.android)
|
||||
<details>
|
||||
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
kotlin.code.style = official
|
||||
version = 2.163.0-dev.3
|
||||
version = 2.163.0-dev.6
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,9 @@
|
||||
package app.revanced.patches.photomath.detection.signature.annotations
|
||||
|
||||
import app.revanced.patcher.annotation.Compatibility
|
||||
import app.revanced.patcher.annotation.Package
|
||||
|
||||
@Compatibility([Package("com.microblink.photomath")])
|
||||
@Target(AnnotationTarget.CLASS)
|
||||
@Retention(AnnotationRetention.RUNTIME)
|
||||
internal annotation class DisableSignatureDetectionCompatibility
|
||||
@@ -0,0 +1,21 @@
|
||||
package app.revanced.patches.photomath.detection.signature.fingerprints
|
||||
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
import org.jf.dexlib2.Opcode
|
||||
|
||||
object CheckSignatureFingerprint : MethodFingerprint(
|
||||
strings = listOf(
|
||||
"currentSignature"
|
||||
),
|
||||
opcodes = listOf(
|
||||
Opcode.CONST_STRING,
|
||||
Opcode.CONST_STRING,
|
||||
Opcode.INVOKE_STATIC,
|
||||
Opcode.INVOKE_STATIC,
|
||||
Opcode.MOVE_RESULT_OBJECT,
|
||||
Opcode.INVOKE_VIRTUAL,
|
||||
Opcode.MOVE_RESULT_OBJECT,
|
||||
Opcode.INVOKE_STATIC,
|
||||
Opcode.MOVE_RESULT,
|
||||
)
|
||||
)
|
||||
@@ -0,0 +1,13 @@
|
||||
package app.revanced.patches.photomath.detection.signature.fingerprints
|
||||
|
||||
import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
import org.jf.dexlib2.AccessFlags
|
||||
|
||||
object MainOnCreateFingerprint : MethodFingerprint(
|
||||
returnType = "V",
|
||||
access = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||
customFingerprint = { methodDef ->
|
||||
methodDef.definingClass == "Lcom/microblink/photomath/PhotoMath;" && methodDef.name == "onCreate"
|
||||
}
|
||||
)
|
||||
@@ -0,0 +1,42 @@
|
||||
package app.revanced.patches.photomath.detection.signature.patch
|
||||
|
||||
import app.revanced.patcher.annotation.Description
|
||||
import app.revanced.patcher.annotation.Version
|
||||
import app.revanced.patcher.data.BytecodeContext
|
||||
import app.revanced.patcher.extensions.instruction
|
||||
import app.revanced.patcher.extensions.replaceInstruction
|
||||
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.patches.photomath.detection.signature.annotations.DisableSignatureDetectionCompatibility
|
||||
import app.revanced.patches.photomath.detection.signature.fingerprints.CheckSignatureFingerprint
|
||||
import app.revanced.patches.photomath.detection.signature.fingerprints.MainOnCreateFingerprint
|
||||
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
|
||||
|
||||
@Description("Disables detection of incorrect signature.")
|
||||
@DisableSignatureDetectionCompatibility
|
||||
@Version("0.0.1")
|
||||
class SignatureDetectionPatch : BytecodePatch(
|
||||
listOf(
|
||||
MainOnCreateFingerprint
|
||||
)
|
||||
) {
|
||||
override fun execute(context: BytecodeContext): PatchResult {
|
||||
val mainOnCreate = MainOnCreateFingerprint.result!!
|
||||
|
||||
val patternResult = CheckSignatureFingerprint.also {
|
||||
it.resolve(context, mainOnCreate.method, mainOnCreate.classDef)
|
||||
}.result!!.scanResult.patternScanResult!!
|
||||
|
||||
mainOnCreate.mutableMethod.apply {
|
||||
val signatureCheckInstruction = instruction(patternResult.endIndex)
|
||||
val checkRegister = (signatureCheckInstruction as OneRegisterInstruction).registerA
|
||||
|
||||
replaceInstruction(signatureCheckInstruction.location.index, "const/4 v$checkRegister, 0x1")
|
||||
}
|
||||
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package app.revanced.patches.photomath.misc.unlockplus.annotations
|
||||
|
||||
import app.revanced.patcher.annotation.Compatibility
|
||||
import app.revanced.patcher.annotation.Package
|
||||
|
||||
@Compatibility([Package("com.microblink.photomath")])
|
||||
@Target(AnnotationTarget.CLASS)
|
||||
@Retention(AnnotationRetention.RUNTIME)
|
||||
internal annotation class UnlockPlusCompatibilty
|
||||
@@ -0,0 +1,16 @@
|
||||
package app.revanced.patches.photomath.misc.unlockplus.fingerprints
|
||||
|
||||
import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
import org.jf.dexlib2.AccessFlags
|
||||
|
||||
object IsPlusUnlockedFingerprint : MethodFingerprint(
|
||||
returnType = "Z",
|
||||
access = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||
strings = listOf(
|
||||
"genius"
|
||||
),
|
||||
customFingerprint = {
|
||||
methodDef -> methodDef.definingClass.endsWith("/User;")
|
||||
}
|
||||
)
|
||||
@@ -0,0 +1,43 @@
|
||||
package app.revanced.patches.photomath.misc.unlockplus.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.patch.BytecodePatch
|
||||
import app.revanced.patcher.patch.PatchResult
|
||||
import app.revanced.patcher.patch.PatchResultSuccess
|
||||
import app.revanced.patcher.patch.annotations.DependsOn
|
||||
import app.revanced.patcher.patch.annotations.Patch
|
||||
import app.revanced.patches.photomath.detection.signature.patch.SignatureDetectionPatch
|
||||
import app.revanced.patches.photomath.misc.unlockplus.annotations.UnlockPlusCompatibilty
|
||||
import app.revanced.patches.photomath.misc.unlockplus.fingerprints.IsPlusUnlockedFingerprint
|
||||
|
||||
@Patch
|
||||
@Name("unlock-plus")
|
||||
@DependsOn([SignatureDetectionPatch::class])
|
||||
@Description("Unlocks plus features.")
|
||||
@UnlockPlusCompatibilty
|
||||
@Version("0.0.1")
|
||||
class UnlockPlusPatch : BytecodePatch(
|
||||
listOf(
|
||||
IsPlusUnlockedFingerprint
|
||||
)
|
||||
) {
|
||||
override fun execute(context: BytecodeContext): PatchResult {
|
||||
IsPlusUnlockedFingerprint.result?.mutableMethod?.apply {
|
||||
addInstructions(
|
||||
0,
|
||||
"""
|
||||
const/4 v0, 0x1
|
||||
return v0
|
||||
"""
|
||||
)
|
||||
} ?: return IsPlusUnlockedFingerprint.toErrorResult()
|
||||
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
package app.revanced.patches.twitter.ad.timeline.fingerprints
|
||||
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
import org.jf.dexlib2.Opcode
|
||||
|
||||
object TimelineTweetJsonParserFingerprint : MethodFingerprint(
|
||||
opcodes = listOf(
|
||||
Opcode.IPUT_OBJECT,
|
||||
Opcode.GOTO,
|
||||
Opcode.SGET_OBJECT,
|
||||
Opcode.INVOKE_VIRTUAL,
|
||||
Opcode.MOVE_RESULT_OBJECT,
|
||||
Opcode.CHECK_CAST,
|
||||
Opcode.IPUT_OBJECT,
|
||||
Opcode.RETURN_VOID,
|
||||
), strings = listOf("tweetPromotedMetadata", "promotedMetadata", "hasModeratedReplies", "conversationAnnotation"),
|
||||
customFingerprint = { methodDef -> methodDef.name == "parseField" }
|
||||
)
|
||||
@@ -1,77 +0,0 @@
|
||||
package app.revanced.patches.twitter.ad.timeline.patch
|
||||
|
||||
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.fingerprint.method.impl.MethodFingerprint
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprintResult
|
||||
import app.revanced.patcher.patch.BytecodePatch
|
||||
import app.revanced.patcher.patch.PatchResult
|
||||
import app.revanced.patcher.patch.PatchResultError
|
||||
import app.revanced.patcher.patch.PatchResultSuccess
|
||||
import app.revanced.patcher.patch.annotations.Patch
|
||||
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
|
||||
import app.revanced.patches.twitter.ad.timeline.annotations.TimelineAdsCompatibility
|
||||
import app.revanced.patches.twitter.ad.timeline.fingerprints.TimelineTweetJsonParserFingerprint
|
||||
import org.jf.dexlib2.Opcode
|
||||
import org.jf.dexlib2.builder.BuilderInstruction
|
||||
import org.jf.dexlib2.builder.instruction.BuilderInstruction22c
|
||||
import org.jf.dexlib2.iface.instruction.ReferenceInstruction
|
||||
import org.jf.dexlib2.iface.reference.FieldReference
|
||||
import org.jf.dexlib2.iface.reference.StringReference
|
||||
|
||||
@Patch
|
||||
@Name("timeline-ads")
|
||||
@Description("Removes ads from the Twitter timeline. Might require clearing app data to remove already cached ads.")
|
||||
@TimelineAdsCompatibility
|
||||
@Version("0.0.1")
|
||||
class TimelineAdsPatch : BytecodePatch(
|
||||
listOf(TimelineTweetJsonParserFingerprint)
|
||||
) {
|
||||
override fun execute(context: BytecodeContext): PatchResult {
|
||||
if (removePromotedAds())
|
||||
return PatchResultError("The instruction for the tweet id field could not be found")
|
||||
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
|
||||
private fun removePromotedAds(): Boolean {
|
||||
val (parserFingerprintResult, parserMethod, instructions) = TimelineTweetJsonParserFingerprint.unwrap()
|
||||
|
||||
// Anchor index
|
||||
val tweetIdFieldInstructionIndex = instructions.indexOfFirst { instruction ->
|
||||
if (instruction.opcode.ordinal != Opcode.CONST_STRING.ordinal) return@indexOfFirst false
|
||||
if (((instruction as? ReferenceInstruction)?.reference as StringReference).string != "tweetSocialProof") return@indexOfFirst false
|
||||
|
||||
// Use the above conditions as an anchor to find the index for the instruction with the field we need
|
||||
return@indexOfFirst true
|
||||
} - 2 // This is where the instruction with the field is located
|
||||
|
||||
// Reference to the tweetId field for of the timeline tweet
|
||||
val tweetIdFieldReference =
|
||||
(parserMethod.instruction(tweetIdFieldInstructionIndex) as? BuilderInstruction22c)?.reference as? FieldReference
|
||||
?: return true
|
||||
|
||||
// Set the tweetId field to null
|
||||
// This will cause twitter to not show the promoted ads, because we set it to null, when the tweet is promoted
|
||||
parserFingerprintResult.mutableMethod.addInstructions(
|
||||
parserFingerprintResult.scanResult.patternScanResult!!.startIndex + 1,
|
||||
"""
|
||||
const/4 v2, 0x0
|
||||
iput-object v2, p0, Lcom/twitter/model/json/timeline/urt/JsonTimelineTweet;->${tweetIdFieldReference.name}:Ljava/lang/String;
|
||||
"""
|
||||
)
|
||||
return false
|
||||
}
|
||||
|
||||
private fun MethodFingerprint.unwrap(): Triple<MethodFingerprintResult, MutableMethod, MutableList<BuilderInstruction>> {
|
||||
val parserFingerprintResult = this.result!!
|
||||
val parserMethod = parserFingerprintResult.mutableMethod
|
||||
val instructions = parserMethod.implementation!!.instructions
|
||||
|
||||
return Triple(parserFingerprintResult, parserMethod, instructions)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package app.revanced.patches.twitter.misc.hook.json.fingerprints
|
||||
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
import org.jf.dexlib2.Opcode
|
||||
|
||||
object JsonHookPatchFingerprint : MethodFingerprint(
|
||||
customFingerprint = { methodDef -> methodDef.name == "<clinit>" },
|
||||
opcodes = listOf(Opcode.IGET_OBJECT)
|
||||
)
|
||||
@@ -0,0 +1,10 @@
|
||||
package app.revanced.patches.twitter.misc.hook.json.fingerprints
|
||||
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
|
||||
object JsonInputStreamFingerprint : MethodFingerprint(
|
||||
customFingerprint = { methodDef ->
|
||||
if (methodDef.parameterTypes.size == 0) false
|
||||
else methodDef.parameterTypes.first() == "Ljava/io/InputStream;"
|
||||
}
|
||||
)
|
||||
@@ -0,0 +1,7 @@
|
||||
package app.revanced.patches.twitter.misc.hook.json.fingerprints
|
||||
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
|
||||
object LoganSquareFingerprint : MethodFingerprint(
|
||||
customFingerprint = { methodDef -> methodDef.definingClass.endsWith("LoganSquare;") }
|
||||
)
|
||||
@@ -0,0 +1,114 @@
|
||||
package app.revanced.patches.twitter.misc.hook.json.patch
|
||||
|
||||
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.fingerprint.method.impl.MethodFingerprintResult
|
||||
import app.revanced.patcher.patch.*
|
||||
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.LoganSquareFingerprint
|
||||
import java.io.InvalidClassException
|
||||
|
||||
@Name("json-hook")
|
||||
@Description("Hooks the stream which reads JSON responses.")
|
||||
@Version("0.0.1")
|
||||
class JsonHookPatch : BytecodePatch(
|
||||
listOf(LoganSquareFingerprint)
|
||||
) {
|
||||
override fun execute(context: BytecodeContext): PatchResult {
|
||||
// Make sure the integrations are present.
|
||||
val jsonHookPatch = context.findClass { it.type == JSON_HOOK_PATCH_CLASS_DESCRIPTOR }
|
||||
?: return PatchResultError("Could not find integrations.")
|
||||
|
||||
// Allow patch to inject hooks into the patches integrations.
|
||||
jsonHookPatchFingerprintResult = JsonHookPatchFingerprint.also {
|
||||
it.resolve(context, jsonHookPatch.immutableClass)
|
||||
}.result ?: return PatchResultError("Unexpected integrations.")
|
||||
|
||||
// Conveniently find the type to hook a method in, via a named field.
|
||||
val jsonFactory = LoganSquareFingerprint.result
|
||||
?.classDef
|
||||
?.fields
|
||||
?.firstOrNull { it.name == "JSON_FACTORY" }
|
||||
?.type
|
||||
.let { type ->
|
||||
context.findClass { it.type == type }?.mutableClass
|
||||
} ?: return PatchResultError("Could not find required class.")
|
||||
|
||||
// Hook the methods first parameter.
|
||||
JsonInputStreamFingerprint
|
||||
.also { it.resolve(context, jsonFactory) }
|
||||
.result
|
||||
?.mutableMethod
|
||||
?.addInstructions(
|
||||
0,
|
||||
"""
|
||||
invoke-static { p1 }, $JSON_HOOK_PATCH_CLASS_DESCRIPTOR->parseJsonHook(Ljava/io/InputStream;)Ljava/io/InputStream;
|
||||
move-result-object p1
|
||||
"""
|
||||
) ?: return PatchResultError("Could not find method to hook.")
|
||||
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a hook class.
|
||||
* The class has to extend on **JsonHook**.
|
||||
* The class has to be a Kotlin object class, or at least have an INSTANCE field of itself.
|
||||
*
|
||||
* @param context The [BytecodeContext] of the current patch.
|
||||
* @param descriptor The class descriptor of the hook.
|
||||
*/
|
||||
internal class Hook(context: BytecodeContext, private val descriptor: String) {
|
||||
private 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 {
|
||||
context.findClass { it.type == descriptor }?.let {
|
||||
it.mutableClass.also { classDef ->
|
||||
if (
|
||||
classDef.superclass != JSON_HOOK_CLASS_DESCRIPTOR ||
|
||||
!classDef.fields.any { field -> field.name == "INSTANCE" }
|
||||
) throw InvalidClassException(classDef.type, "Not a hook class")
|
||||
|
||||
}
|
||||
} ?: throw ClassNotFoundException("Failed to find hook class")
|
||||
}
|
||||
}
|
||||
|
||||
private companion object {
|
||||
const val JSON_HOOK_CLASS_NAMESPACE = "app/revanced/twitter/patches/hook/json"
|
||||
|
||||
const val JSON_HOOK_PATCH_CLASS_DESCRIPTOR = "L$JSON_HOOK_CLASS_NAMESPACE/JsonHookPatch;"
|
||||
|
||||
const val BASE_PATCH_CLASS_NAME = "BaseJsonHook"
|
||||
|
||||
const val JSON_HOOK_CLASS_DESCRIPTOR = "L$JSON_HOOK_CLASS_NAMESPACE/$BASE_PATCH_CLASS_NAME;"
|
||||
|
||||
private lateinit var jsonHookPatchFingerprintResult: MethodFingerprintResult
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package app.revanced.patches.twitter.misc.hook.patch
|
||||
|
||||
import app.revanced.patcher.data.BytecodeContext
|
||||
import app.revanced.patcher.patch.BytecodePatch
|
||||
import app.revanced.patcher.patch.PatchResultError
|
||||
import app.revanced.patcher.patch.PatchResultSuccess
|
||||
import app.revanced.patcher.patch.annotations.DependsOn
|
||||
import app.revanced.patches.twitter.misc.hook.json.patch.JsonHookPatch
|
||||
|
||||
@DependsOn([JsonHookPatch::class])
|
||||
abstract class BaseHookPatchPatch(private val hookClassDescriptor: String) : BytecodePatch() {
|
||||
override fun execute(context: BytecodeContext) = try {
|
||||
PatchResultSuccess().also { JsonHookPatch.Hook(context, hookClassDescriptor).add() }
|
||||
} catch (ex: Exception) {
|
||||
PatchResultError(ex)
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,13 @@
|
||||
package app.revanced.patches.twitter.ad.timeline.annotations
|
||||
package app.revanced.patches.twitter.misc.hook.patch.ads.annotations
|
||||
|
||||
import app.revanced.patcher.annotation.Compatibility
|
||||
import app.revanced.patcher.annotation.Package
|
||||
|
||||
@Compatibility(
|
||||
[Package(
|
||||
"com.twitter.android", arrayOf("9.65.3-release.0")
|
||||
"com.twitter.android"
|
||||
)]
|
||||
)
|
||||
@Target(AnnotationTarget.CLASS)
|
||||
@Retention(AnnotationRetention.RUNTIME)
|
||||
internal annotation class TimelineAdsCompatibility
|
||||
internal annotation class HideAdsCompatibility
|
||||
@@ -0,0 +1,22 @@
|
||||
package app.revanced.patches.twitter.misc.hook.patch.ads.patch
|
||||
|
||||
import app.revanced.patcher.annotation.Description
|
||||
import app.revanced.patcher.annotation.Name
|
||||
import app.revanced.patcher.annotation.Version
|
||||
import app.revanced.patcher.patch.annotations.DependsOn
|
||||
import app.revanced.patcher.patch.annotations.Patch
|
||||
import app.revanced.patches.twitter.misc.hook.json.patch.JsonHookPatch
|
||||
import app.revanced.patches.twitter.misc.hook.patch.BaseHookPatchPatch
|
||||
import app.revanced.patches.twitter.misc.hook.patch.ads.annotations.HideAdsCompatibility
|
||||
|
||||
@Patch
|
||||
@Name("hide-ads")
|
||||
@DependsOn([JsonHookPatch::class])
|
||||
@Description("Hides ads.")
|
||||
@HideAdsCompatibility
|
||||
@Version("0.0.1")
|
||||
class HideAdsPatch : BaseHookPatchPatch(HOOK_CLASS_DESCRIPTOR) {
|
||||
private companion object {
|
||||
const val HOOK_CLASS_DESCRIPTOR = "Lapp/revanced/twitter/patches/hook/patch/ads/AdsHook;"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package app.revanced.patches.twitter.misc.hook.patch.recommendation.annotations
|
||||
|
||||
import app.revanced.patcher.annotation.Compatibility
|
||||
import app.revanced.patcher.annotation.Package
|
||||
|
||||
@Compatibility(
|
||||
[Package(
|
||||
"com.twitter.android"
|
||||
)]
|
||||
)
|
||||
@Target(AnnotationTarget.CLASS)
|
||||
@Retention(AnnotationRetention.RUNTIME)
|
||||
internal annotation class HideRecommendedUsersCompatibility
|
||||
@@ -0,0 +1,23 @@
|
||||
package app.revanced.patches.twitter.misc.hook.patch.recommendation.patch
|
||||
|
||||
import app.revanced.patcher.annotation.Description
|
||||
import app.revanced.patcher.annotation.Name
|
||||
import app.revanced.patcher.annotation.Version
|
||||
import app.revanced.patcher.patch.annotations.DependsOn
|
||||
import app.revanced.patcher.patch.annotations.Patch
|
||||
import app.revanced.patches.twitter.misc.hook.json.patch.JsonHookPatch
|
||||
import app.revanced.patches.twitter.misc.hook.patch.BaseHookPatchPatch
|
||||
import app.revanced.patches.twitter.misc.hook.patch.recommendation.annotations.HideRecommendedUsersCompatibility
|
||||
|
||||
@Patch
|
||||
@Name("hide-recommended-users")
|
||||
@DependsOn([JsonHookPatch::class])
|
||||
@Description("Hides recommended users.")
|
||||
@HideRecommendedUsersCompatibility
|
||||
@Version("0.0.1")
|
||||
class HideRecommendedUsersPatch : BaseHookPatchPatch(HOOK_CLASS_DESCRIPTOR) {
|
||||
private companion object {
|
||||
const val HOOK_CLASS_DESCRIPTOR =
|
||||
"Lapp/revanced/twitter/patches/hook/patch/recommendation/RecommendedUsersHook;"
|
||||
}
|
||||
}
|
||||
@@ -180,10 +180,10 @@ class GeneralAdsResourcePatch : ResourcePatch {
|
||||
),
|
||||
SwitchPreference(
|
||||
"revanced_adremover_info_panel",
|
||||
StringResource("revanced_adremover_info_panel_enabled_title", "Hide info-panels"),
|
||||
StringResource("revanced_adremover_info_panel_enabled_title", "Hide info panels"),
|
||||
true,
|
||||
StringResource("revanced_adremover_info_panel_enabled_summary_on", "Info-panels are hidden"),
|
||||
StringResource("revanced_adremover_info_panel_enabled_summary_off", "Info-panels are shown")
|
||||
StringResource("revanced_adremover_info_panel_enabled_summary_on", "Info panels are hidden"),
|
||||
StringResource("revanced_adremover_info_panel_enabled_summary_off", "Info panels are shown")
|
||||
),
|
||||
SwitchPreference(
|
||||
"revanced_adremover_medical_panel",
|
||||
|
||||
@@ -34,10 +34,10 @@ class AutoCaptionsPatch : BytecodePatch(
|
||||
SettingsPatch.PreferenceScreen.LAYOUT.addPreferences(
|
||||
SwitchPreference(
|
||||
"revanced_autocaptions_enabled",
|
||||
StringResource("revanced_autocaptions_enabled_title", "Disable auto-captions"),
|
||||
StringResource("revanced_autocaptions_enabled_title", "Disable auto captions"),
|
||||
false,
|
||||
StringResource("revanced_autocaptions_summary_on", "Auto-captions are disabled"),
|
||||
StringResource("revanced_autocaptions_summary_off", "Auto-captions are enabled")
|
||||
StringResource("revanced_autocaptions_summary_on", "Auto captions are disabled"),
|
||||
StringResource("revanced_autocaptions_summary_off", "Auto captions are enabled")
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
@@ -10,10 +10,10 @@ import app.revanced.patcher.patch.PatchResult
|
||||
import app.revanced.patcher.patch.PatchResultError
|
||||
import app.revanced.patcher.patch.PatchResultSuccess
|
||||
import app.revanced.patcher.patch.annotations.DependsOn
|
||||
import app.revanced.patches.music.layout.upgradebutton.fingerprints.PivotBarConstructorFingerprint
|
||||
import app.revanced.patches.shared.mapping.misc.patch.ResourceMappingPatch
|
||||
import app.revanced.patches.youtube.layout.buttons.pivotbar.shared.annotations.PivotBarCompatibility
|
||||
import app.revanced.patches.youtube.layout.buttons.pivotbar.shared.fingerprints.InitializeButtonsFingerprint
|
||||
import app.revanced.patches.youtube.layout.buttons.pivotbar.shared.fingerprints.PivotBarConstructorFingerprint
|
||||
|
||||
@DependsOn([ResourceMappingPatch::class])
|
||||
@PivotBarCompatibility
|
||||
|
||||
@@ -44,11 +44,11 @@ class HidePlayerButtonsPatch : BytecodePatch(
|
||||
false,
|
||||
StringResource(
|
||||
"revanced_hide_player_buttons_summary_on",
|
||||
"The buttons are hidden"
|
||||
"Buttons are hidden"
|
||||
),
|
||||
StringResource(
|
||||
"revanced_hide_player_buttons_summary_off",
|
||||
"The buttons are shown"
|
||||
"Buttons are shown"
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
@@ -28,10 +28,10 @@ class HideEndscreenCardsResourcePatch : ResourcePatch {
|
||||
SettingsPatch.PreferenceScreen.LAYOUT.addPreferences(
|
||||
SwitchPreference(
|
||||
"revanced_hide_endscreen_cards",
|
||||
StringResource("revanced_hide_endscreen_cards_title", "Hide end-screen cards"),
|
||||
StringResource("revanced_hide_endscreen_cards_title", "Hide end screen cards"),
|
||||
true,
|
||||
StringResource("revanced_hide_endscreen_cards_summary_on", "End-screen cards are hidden"),
|
||||
StringResource("revanced_hide_endscreen_cards_summary_off", "End-screen cards are shown")
|
||||
StringResource("revanced_hide_endscreen_cards_summary_on", "End screen cards are hidden"),
|
||||
StringResource("revanced_hide_endscreen_cards_summary_off", "End screen cards are shown")
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
@@ -25,10 +25,10 @@ import org.jf.dexlib2.builder.instruction.BuilderInstruction35c
|
||||
@Patch
|
||||
@DependsOn([IntegrationsPatch::class, HideInfocardsResourcePatch::class])
|
||||
@Name("hide-info-cards")
|
||||
@Description("Hides info-cards in videos.")
|
||||
@Description("Hides info cards in videos.")
|
||||
@HideInfocardsCompatibility
|
||||
@Version("0.0.1")
|
||||
class HideInfocardsPatch : BytecodePatch(
|
||||
class HideInfoCardsPatch : BytecodePatch(
|
||||
listOf(
|
||||
InfocardsIncognitoParentFingerprint,
|
||||
InfocardsMethodCallFingerprint,
|
||||
@@ -47,7 +47,7 @@ class HideInfocardsPatch : BytecodePatch(
|
||||
addInstructions(
|
||||
invokeInstructionIndex,
|
||||
"invoke-static {v${(instruction(invokeInstructionIndex) as? BuilderInstruction35c)?.registerC}}," +
|
||||
" Lapp/revanced/integrations/patches/HideInfocardsPatch;->hideInfocardsIncognito(Landroid/view/View;)V"
|
||||
" Lapp/revanced/integrations/patches/HideInfoCardsPatch;->hideInfoCardsIncognito(Landroid/view/View;)V"
|
||||
)
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ class HideInfocardsPatch : BytecodePatch(
|
||||
|
||||
hideInfocardsCallMethod.addInstructions(
|
||||
invokeInterfaceIndex, """
|
||||
invoke-static {}, Lapp/revanced/integrations/patches/HideInfocardsPatch;->hideInfocardsMethodCall()Z
|
||||
invoke-static {}, Lapp/revanced/integrations/patches/HideInfoCardsPatch;->hideInfoCardsMethodCall()Z
|
||||
move-result v$toggleRegister
|
||||
if-nez v$toggleRegister, :hide_info_cards
|
||||
""",
|
||||
@@ -24,10 +24,10 @@ class HideInfocardsResourcePatch : ResourcePatch {
|
||||
SettingsPatch.PreferenceScreen.LAYOUT.addPreferences(
|
||||
SwitchPreference(
|
||||
"revanced_hide_infocards",
|
||||
StringResource("revanced_hide_infocards_title", "Hide info-cards"),
|
||||
StringResource("revanced_hide_infocards_title", "Hide info cards"),
|
||||
true,
|
||||
StringResource("revanced_hide_infocards_summary_on", "Info-cards are hidden"),
|
||||
StringResource("revanced_hide_infocards_summary_off", "Info-cards are shown")
|
||||
StringResource("revanced_hide_infocards_summary_on", "Info cards are hidden"),
|
||||
StringResource("revanced_hide_infocards_summary_off", "Info cards are shown")
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
@@ -46,9 +46,9 @@ class HideSeekbarPatch : BytecodePatch(
|
||||
const/4 v0, 0x0
|
||||
invoke-static { }, Lapp/revanced/integrations/patches/HideSeekbarPatch;->hideSeekbar()Z
|
||||
move-result v0
|
||||
if-eqz v0, :hide_time_and_seekbar
|
||||
if-eqz v0, :hide_seekbar
|
||||
return-void
|
||||
:hide_time_and_seekbar
|
||||
:hide_seekbar
|
||||
nop
|
||||
"""
|
||||
)
|
||||
|
||||
@@ -41,11 +41,11 @@ class HideTimePatch : BytecodePatch(
|
||||
|
||||
TimeCounterFingerprint.result!!.mutableMethod.addInstructions(
|
||||
0, """
|
||||
invoke-static { }, Lapp/revanced/integrations/patches/HideTimeAndSeekbarPatch;->hideTimeAndSeekbar()Z
|
||||
invoke-static { }, Lapp/revanced/integrations/patches/HideTimePatch;->hideTime()Z
|
||||
move-result v0
|
||||
if-eqz v0, :hide_time_and_seekbar
|
||||
if-eqz v0, :hide_time
|
||||
return-void
|
||||
:hide_time_and_seekbar
|
||||
:hide_time
|
||||
nop
|
||||
"""
|
||||
)
|
||||
|
||||
@@ -13,6 +13,8 @@ import app.revanced.patcher.patch.PatchResultSuccess
|
||||
import app.revanced.patcher.patch.annotations.DependsOn
|
||||
import app.revanced.patcher.patch.annotations.Patch
|
||||
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
|
||||
import app.revanced.patches.shared.settings.preference.impl.StringResource
|
||||
import app.revanced.patches.shared.settings.preference.impl.SwitchPreference
|
||||
import app.revanced.patches.youtube.layout.tabletminiplayer.annotations.TabletMiniPlayerCompatibility
|
||||
import app.revanced.patches.youtube.layout.tabletminiplayer.fingerprints.MiniPlayerDimensionsCalculatorFingerprint
|
||||
import app.revanced.patches.youtube.layout.tabletminiplayer.fingerprints.MiniPlayerOverrideFingerprint
|
||||
@@ -20,8 +22,6 @@ import app.revanced.patches.youtube.layout.tabletminiplayer.fingerprints.MiniPla
|
||||
import app.revanced.patches.youtube.layout.tabletminiplayer.fingerprints.MiniPlayerResponseModelSizeCheckFingerprint
|
||||
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
|
||||
import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
|
||||
import app.revanced.patches.shared.settings.preference.impl.StringResource
|
||||
import app.revanced.patches.shared.settings.preference.impl.SwitchPreference
|
||||
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
|
||||
|
||||
@Patch
|
||||
@@ -40,10 +40,10 @@ class TabletMiniPlayerPatch : BytecodePatch(
|
||||
SettingsPatch.PreferenceScreen.LAYOUT.addPreferences(
|
||||
SwitchPreference(
|
||||
"revanced_tablet_miniplayer",
|
||||
StringResource("revanced_tablet_miniplayer_title", "Enable the tablet Mini-player"),
|
||||
StringResource("revanced_tablet_miniplayer_title", "Enable tablet mini player"),
|
||||
false,
|
||||
StringResource("revanced_tablet_miniplayer_summary_on", "Tablet Mini-player is enabled"),
|
||||
StringResource("revanced_tablet_miniplayer_summary_off", "Tablet Mini-player is disabled")
|
||||
StringResource("revanced_tablet_miniplayer_summary_on", "Mini player is enabled"),
|
||||
StringResource("revanced_tablet_miniplayer_summary_off", "Mini player is disabled")
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ class OpenLinksDirectlyPatch : BytecodePatch(
|
||||
"invoke-static {v$uriRegister}," +
|
||||
"Lapp/revanced/integrations/patches/OpenLinksDirectlyPatch;" +
|
||||
"->" +
|
||||
"transformRedirectUri(Ljava/lang/String;)Landroid/net/Uri;"
|
||||
"parseRedirectUri(Ljava/lang/String;)Landroid/net/Uri;"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user