feat(YouTube): replace with a fingerprint that supports a wider range of versions

This commit is contained in:
inotia00
2024-10-06 18:41:52 +09:00
parent 12127d6f25
commit 41e00d6a4f
13 changed files with 173 additions and 43 deletions

View File

@ -50,6 +50,7 @@ import app.revanced.patches.youtube.video.information.VideoInformationPatch
import app.revanced.util.REGISTER_TEMPLATE_REPLACEMENT
import app.revanced.util.findMethodOrThrow
import app.revanced.util.getReference
import app.revanced.util.indexOfFirstInstruction
import app.revanced.util.indexOfFirstInstructionOrThrow
import app.revanced.util.indexOfFirstInstructionReversedOrThrow
import app.revanced.util.indexOfFirstWideLiteralInstructionValueOrThrow
@ -147,13 +148,15 @@ object PlayerComponentsPatch : BaseBytecodePatch(
hookInitVideoPanel(1)
} else {
val syntheticIndex =
indexOfFirstInstructionOrThrow(Opcode.NEW_INSTANCE)
val syntheticReference =
getInstruction<ReferenceInstruction>(syntheticIndex).reference.toString()
indexOfFirstInstruction(0, Opcode.NEW_INSTANCE)
if (syntheticIndex >= 0) {
val syntheticReference =
getInstruction<ReferenceInstruction>(syntheticIndex).reference.toString()
context.findMethodOrThrow(syntheticReference) {
name == "onClick"
}.hookInitVideoPanel(0)
context.findMethodOrThrow(syntheticReference) {
name == "onClick"
}.hookInitVideoPanel(0)
}
}
}
}