feat(youtube/return-youtube-dislike): support for shorts (#1596)

Signed-off-by: oSumAtrIX <johan.melkonyan1@web.de>
Co-authored-by: oSumAtrIX <johan.melkonyan1@web.de>
This commit is contained in:
LisoUseInAIKyrios
2023-02-24 02:59:07 +01:00
committed by GitHub
co-authored by oSumAtrIX
parent dc3c6993e8
commit c36a12bd42
4 changed files with 144 additions and 44 deletions
@@ -1,16 +1,31 @@
package app.revanced.patches.youtube.misc.video.videoid.fingerprint
import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import org.jf.dexlib2.AccessFlags
import org.jf.dexlib2.Opcode
@FuzzyPatternScanMethod(2)
object VideoIdFingerprint : MethodFingerprint(
"V",
AccessFlags.DECLARED_SYNCHRONIZED or AccessFlags.FINAL or AccessFlags.PUBLIC,
listOf("L"),
listOf(Opcode.INVOKE_INTERFACE),
customFingerprint = {
it.definingClass.endsWith("PlaybackLifecycleMonitor;")
}
returnType = "V",
access = AccessFlags.PUBLIC or AccessFlags.FINAL,
parameters = listOf("L"),
opcodes = listOf(
Opcode.IF_EQZ,
Opcode.INVOKE_VIRTUAL,
Opcode.MOVE_RESULT_OBJECT,
Opcode.INVOKE_INTERFACE,
Opcode.MOVE_RESULT_OBJECT,
Opcode.IF_EQZ,
Opcode.IGET_OBJECT,
Opcode.INVOKE_VIRTUAL,
Opcode.MOVE_RESULT_OBJECT,
Opcode.INVOKE_INTERFACE,
Opcode.MOVE_RESULT_OBJECT,
Opcode.INVOKE_INTERFACE,
Opcode.MOVE_RESULT_OBJECT
),
null,
{ it.definingClass.endsWith("SubtitlesOverlayPresenter;") }
)
@@ -1,5 +1,6 @@
package app.revanced.patches.youtube.misc.video.videoid.patch
import app.revanced.extensions.toErrorResult
import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
@@ -22,17 +23,18 @@ import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
@Version("0.0.1")
@DependsOn([IntegrationsPatch::class])
class VideoIdPatch : BytecodePatch(
listOf(
VideoIdFingerprint
)
listOf(VideoIdFingerprint)
) {
override fun execute(context: BytecodeContext): PatchResult {
with(VideoIdFingerprint.result!!) {
insertMethod = mutableMethod
insertIndex = scanResult.patternScanResult!!.endIndex + 2
VideoIdFingerprint.result?.let {
val videoIdRegisterInstructionIndex = it.scanResult.patternScanResult!!.endIndex
videoIdRegister = (insertMethod.instruction(insertIndex - 1) as OneRegisterInstruction).registerA
}
with(it.mutableMethod) {
insertMethod = this
videoIdRegister = (instruction(videoIdRegisterInstructionIndex) as OneRegisterInstruction).registerA
insertIndex = videoIdRegisterInstructionIndex + 1
}
} ?: return VideoIdFingerprint.toErrorResult()
return PatchResultSuccess()
}
@@ -49,10 +51,15 @@ class VideoIdPatch : BytecodePatch(
*/
fun injectCall(
methodDescriptor: String
) = insertMethod.addInstructions(
insertIndex, // move-result-object offset
"invoke-static {v$videoIdRegister}, $methodDescriptor"
)
) {
insertMethod.addInstructions(
// TODO: The order has been proven to not be required, so remove the logic for keeping order.
// Keep injection calls in the order they're added:
// Increment index. So if additional injection calls are added, those calls run after this injection call.
insertIndex++,
"invoke-static {v$videoIdRegister}, $methodDescriptor"
)
}
}
}