fix(YouTube/Hide load more button): Hide load more button hides the expand button in the channel information

This commit is contained in:
inotia00 2023-10-27 12:37:15 +09:00
parent 8ad7f3c47d
commit 8ea39970f8

View File

@ -5,6 +5,7 @@ import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.patch.BytecodePatch 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.CompatiblePackage
import app.revanced.patcher.patch.annotation.Patch import app.revanced.patcher.patch.annotation.Patch
import app.revanced.patches.youtube.general.loadmorebutton.fingerprints.LoadMoreButtonFingerprint import app.revanced.patches.youtube.general.loadmorebutton.fingerprints.LoadMoreButtonFingerprint
@ -49,14 +50,21 @@ object LoadMoreButtonPatch : BytecodePatch(
) { ) {
override fun execute(context: BytecodeContext) { override fun execute(context: BytecodeContext) {
LoadMoreButtonFingerprint.result?.let { LoadMoreButtonFingerprint.result?.let {
it.mutableMethod.apply { val getViewMethod =
val targetIndex = it.scanResult.patternScanResult!!.endIndex it.mutableClass.methods.find { method ->
method.parameters.isEmpty() &&
method.returnType == "Landroid/view/View;"
}
getViewMethod?.apply {
val targetIndex = implementation!!.instructions.size - 1
val targetRegister = getInstruction<OneRegisterInstruction>(targetIndex).registerA val targetRegister = getInstruction<OneRegisterInstruction>(targetIndex).registerA
addInstruction( addInstruction(
targetIndex + 1, targetIndex,
"invoke-static {v$targetRegister}, $GENERAL->hideLoadMoreButton(Landroid/view/View;)V" "invoke-static {v$targetRegister}, $GENERAL->hideLoadMoreButton(Landroid/view/View;)V"
) )
} } ?: throw PatchException("Failed to find getView method")
} ?: throw LoadMoreButtonFingerprint.exception } ?: throw LoadMoreButtonFingerprint.exception
/** /**