feat(youtube): add enable-new-comment-popup-panels patch

This commit is contained in:
inotia00
2023-07-09 11:39:07 +09:00
parent e4b1c487b7
commit 66113e0655
4 changed files with 80 additions and 0 deletions

View File

@ -0,0 +1,13 @@
package app.revanced.patches.youtube.shorts.commentpopuppanels.fingerprints
import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import app.revanced.util.bytecode.isWide32LiteralExists
import org.jf.dexlib2.AccessFlags
object ReelWatchFragmentBuilderFingerprint : MethodFingerprint(
returnType = "Landroid/view/View;",
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
parameters = listOf("Landroid/view/LayoutInflater;", "Landroid/view/ViewGroup;", "Landroid/os/Bundle;"),
customFingerprint = { methodDef, _ -> methodDef.isWide32LiteralExists(45401415) }
)

View File

@ -0,0 +1,60 @@
package app.revanced.patches.youtube.shorts.commentpopuppanels.patch
import app.revanced.extensions.toErrorResult
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.InstructionExtensions.addInstructions
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.youtube.shorts.commentpopuppanels.fingerprints.ReelWatchFragmentBuilderFingerprint
import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility
import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch
import app.revanced.util.bytecode.getWide32LiteralIndex
import app.revanced.util.integrations.Constants.SHORTS
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
@Patch
@Name("enable-new-comment-popup-panels")
@Description("Enables a new type of comment popup panel in the shorts player.")
@DependsOn([SettingsPatch::class])
@YouTubeCompatibility
@Version("0.0.1")
class NewCommentPopupPanelsPatch : BytecodePatch(
listOf(ReelWatchFragmentBuilderFingerprint)
) {
override fun execute(context: BytecodeContext): PatchResult {
ReelWatchFragmentBuilderFingerprint.result?.let {
it.mutableMethod.apply {
val targetIndex = getWide32LiteralIndex(45401415) + 2
val targetRegister = getInstruction<OneRegisterInstruction>(targetIndex).registerA
addInstructions(
targetIndex + 1, """
invoke-static {}, $SHORTS->enableNewCommentPopupPanels()Z
move-result v$targetRegister
"""
)
}
} ?: return ReelWatchFragmentBuilderFingerprint.toErrorResult()
/**
* Add settings
*/
SettingsPatch.addPreference(
arrayOf(
"SETTINGS: ENABLE_NEW_COMMENT_POPUP_PANELS"
)
)
SettingsPatch.updatePatchStatus("enable-new-comment-popup-panels")
return PatchResultSuccess()
}
}