generated from ReVanced/revanced-patches-template
-
-
Notifications
You must be signed in to change notification settings - Fork 259
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(twitch/show-deleted-messages):
show-deleted-messages
patch (#1030
- Loading branch information
1 parent
ead676d
commit 34c73b7
Showing
4 changed files
with
90 additions
and
0 deletions.
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
...p/revanced/patches/twitch/chat/antidelete/annotations/ShowDeletedMessagesCompatibility.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package app.revanced.patches.twitch.chat.antidelete.annotations | ||
|
||
import app.revanced.patcher.annotation.Compatibility | ||
import app.revanced.patcher.annotation.Package | ||
|
||
@Compatibility([Package("tv.twitch.android.app")]) | ||
@Target(AnnotationTarget.CLASS) | ||
@Retention(AnnotationRetention.RUNTIME) | ||
internal annotation class ShowDeletedMessagesCompatibility | ||
|
19 changes: 19 additions & 0 deletions
19
...patches/twitch/chat/antidelete/fingerprints/DeletedMessageClickableSpanCtorFingerprint.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package app.revanced.patches.twitch.chat.antidelete.fingerprints | ||
|
||
import app.revanced.patcher.annotation.Name | ||
import app.revanced.patcher.annotation.Version | ||
import app.revanced.patcher.extensions.or | ||
|
||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint | ||
import app.revanced.patches.twitch.chat.antidelete.annotations.ShowDeletedMessagesCompatibility | ||
import org.jf.dexlib2.AccessFlags | ||
|
||
@Name("deleted-msg-span-ctor-fingerprint") | ||
@ShowDeletedMessagesCompatibility | ||
@Version("0.0.1") | ||
object DeletedMessageClickableSpanCtorFingerprint : MethodFingerprint( | ||
"V", AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR, | ||
customFingerprint = { methodDef -> | ||
methodDef.definingClass.endsWith("DeletedMessageClickableSpan;") | ||
} | ||
) |
16 changes: 16 additions & 0 deletions
16
...in/app/revanced/patches/twitch/chat/antidelete/fingerprints/SetHasModAccessFingerprint.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package app.revanced.patches.twitch.chat.antidelete.fingerprints | ||
|
||
import app.revanced.patcher.annotation.Name | ||
import app.revanced.patcher.annotation.Version | ||
|
||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint | ||
import app.revanced.patches.twitch.chat.antidelete.annotations.ShowDeletedMessagesCompatibility | ||
|
||
@Name("has-mod-access-fingerprint") | ||
@ShowDeletedMessagesCompatibility | ||
@Version("0.0.1") | ||
object SetHasModAccessFingerprint : MethodFingerprint( | ||
customFingerprint = { methodDef -> | ||
methodDef.definingClass.endsWith("DeletedMessageClickableSpan;") && methodDef.name == "setHasModAccess" | ||
} | ||
) |
45 changes: 45 additions & 0 deletions
45
...main/kotlin/app/revanced/patches/twitch/chat/antidelete/patch/ShowDeletedMessagesPatch.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package app.revanced.patches.twitch.chat.antidelete.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.* | ||
import app.revanced.patcher.patch.* | ||
import app.revanced.patcher.patch.annotations.Patch | ||
import app.revanced.patches.twitch.chat.antidelete.annotations.ShowDeletedMessagesCompatibility | ||
import app.revanced.patches.twitch.chat.antidelete.fingerprints.* | ||
import org.jf.dexlib2.Opcode | ||
import org.jf.dexlib2.builder.instruction.BuilderInstruction10x | ||
|
||
@Patch | ||
@Name("show-deleted-messages") | ||
@Description("Shows deleted chat messages behind a clickable spoiler.") | ||
@ShowDeletedMessagesCompatibility | ||
@Version("0.0.1") | ||
class ShowDeletedMessagesPatch : BytecodePatch( | ||
listOf( | ||
SetHasModAccessFingerprint, | ||
DeletedMessageClickableSpanCtorFingerprint, | ||
) | ||
) { | ||
override fun execute(context: BytecodeContext): PatchResult { | ||
// Force set hasModAccess member to true in constructor | ||
with(DeletedMessageClickableSpanCtorFingerprint.result!!.mutableMethod) { | ||
addInstructions( | ||
implementation!!.instructions.lastIndex, /* place in front of return-void */ | ||
""" | ||
const/4 v0, 1 | ||
iput-boolean v0, p0, $definingClass->hasModAccess:Z | ||
""" | ||
) | ||
} | ||
|
||
// Disable setHasModAccess setter | ||
with(SetHasModAccessFingerprint.result!!.mutableMethod.implementation!!) { | ||
addInstruction(0, BuilderInstruction10x(Opcode.RETURN_VOID)) | ||
} | ||
|
||
return PatchResultSuccess() | ||
} | ||
} |