forked from crimera/piko
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Twitter): Added
Enable force HD videos
patch
- Loading branch information
Showing
3 changed files
with
83 additions
and
0 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
src/main/kotlin/crimera/patches/twitter/timeline/videoEntity/ForceHDPatch.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,25 @@ | ||
package crimera.patches.twitter.timeline.videoEntity | ||
|
||
import app.revanced.patcher.data.BytecodeContext | ||
import app.revanced.patcher.patch.BytecodePatch | ||
import app.revanced.patcher.patch.annotation.Patch | ||
import crimera.patches.twitter.misc.settings.SettingsPatch | ||
import app.revanced.patcher.patch.annotation.CompatiblePackage | ||
import crimera.patches.twitter.misc.settings.fingerprints.SettingsStatusLoadFingerprint | ||
|
||
|
||
@Patch( | ||
name = "Enable force HD videos", | ||
description = "Videos will be played in HD", | ||
dependencies = [SettingsPatch::class,VideoEntityPatch::class], | ||
compatiblePackages = [CompatiblePackage("com.twitter.android")], | ||
requiresIntegrations = true | ||
) | ||
@Suppress("unused") | ||
object ForceHDPatch:BytecodePatch( | ||
setOf(SettingsStatusLoadFingerprint) | ||
) { | ||
override fun execute(context: BytecodeContext) { | ||
SettingsStatusLoadFingerprint.enableSettings("enableForceHD") | ||
} | ||
} |
56 changes: 56 additions & 0 deletions
56
src/main/kotlin/crimera/patches/twitter/timeline/videoEntity/VideoEntityPatch.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,56 @@ | ||
package crimera.patches.twitter.timeline.videoEntity | ||
|
||
import app.revanced.patcher.data.BytecodeContext | ||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions | ||
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction | ||
import app.revanced.patcher.extensions.InstructionExtensions.getInstructions | ||
import app.revanced.patcher.fingerprint.MethodFingerprint | ||
import app.revanced.patcher.patch.BytecodePatch | ||
import app.revanced.patcher.patch.PatchException | ||
import app.revanced.patcher.patch.annotation.CompatiblePackage | ||
import app.revanced.patcher.patch.annotation.Patch | ||
import com.android.tools.smali.dexlib2.Opcode | ||
import com.android.tools.smali.dexlib2.dexbacked.reference.DexBackedMethodReference | ||
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction | ||
import crimera.patches.twitter.misc.settings.SettingsPatch | ||
|
||
object VideoEntityFinderFingerprint: MethodFingerprint( | ||
strings = listOf( | ||
"video_configurations_amplify_video_bird_url_android_enabled", | ||
), | ||
returnType = "Ljava/lang/String" | ||
) | ||
|
||
@Patch( | ||
compatiblePackages = [CompatiblePackage("com.twitter.android")], | ||
requiresIntegrations = true | ||
) | ||
@Suppress("unused") | ||
object VideoEntityPatch:BytecodePatch( | ||
setOf(VideoEntityFinderFingerprint) | ||
) { | ||
override fun execute(context: BytecodeContext) { | ||
val result = VideoEntityFinderFingerprint.result | ||
?:throw PatchException("VideoEntityFinderFingerprint not found") | ||
|
||
val m1 = result.mutableMethod | ||
val i1 = m1.getInstructions() | ||
|
||
val f1 = i1.last { it.opcode == Opcode.INVOKE_STATIC }.location.index | ||
val fr = m1.getInstruction<ReferenceInstruction>(f1).reference as DexBackedMethodReference | ||
val clsName = fr.definingClass | ||
val mName = fr.name | ||
|
||
val cls = context.findClass(clsName)!!.mutableClass | ||
val m2 = cls.methods.find { it.name == mName } | ||
val i2 = m2!!.getInstructions() | ||
|
||
val iget = i2.find { it.opcode == Opcode.IGET_OBJECT }!!.location.index | ||
m2.addInstructions(iget+1,""" | ||
invoke-static {p1}, ${SettingsPatch.PATCHES_DESCRIPTOR}/TimelineVideoEntity;->videoEnity(Ljava/util/List;)Ljava/util/List; | ||
move-result-object p1 | ||
""".trimIndent()) | ||
|
||
|
||
} | ||
} |
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