mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-06-12 21:27:43 +02:00
feat(youtube): add hide-feed-flyout-panel
patch
This commit is contained in:
@ -0,0 +1,16 @@
|
||||
package app.revanced.patches.youtube.flyoutpanel.feed.fingerprints
|
||||
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
import org.jf.dexlib2.Opcode
|
||||
|
||||
object BottomSheetMenuItemBuilderFingerprint : MethodFingerprint(
|
||||
returnType = "L",
|
||||
parameters = listOf("L"),
|
||||
opcodes = listOf(
|
||||
Opcode.INVOKE_STATIC,
|
||||
Opcode.MOVE_RESULT_OBJECT,
|
||||
Opcode.INVOKE_STATIC,
|
||||
Opcode.MOVE_RESULT_OBJECT
|
||||
),
|
||||
strings = listOf("ElementTransformer, ElementPresenter and InteractionLogger cannot be null")
|
||||
)
|
@ -0,0 +1,66 @@
|
||||
package app.revanced.patches.youtube.flyoutpanel.feed.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.PatchResultError
|
||||
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.flyoutpanel.feed.fingerprints.BottomSheetMenuItemBuilderFingerprint
|
||||
import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility
|
||||
import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch
|
||||
import app.revanced.util.integrations.Constants.FLYOUT_PANEL
|
||||
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
|
||||
import org.jf.dexlib2.iface.instruction.ReferenceInstruction
|
||||
|
||||
@Patch
|
||||
@Name("hide-feed-flyout-panel")
|
||||
@Description("Hides feed flyout panel components.")
|
||||
@DependsOn([SettingsPatch::class])
|
||||
@YouTubeCompatibility
|
||||
@Version("0.0.1")
|
||||
class FeedFlyoutPanelPatch : BytecodePatch(
|
||||
listOf(BottomSheetMenuItemBuilderFingerprint)
|
||||
) {
|
||||
override fun execute(context: BytecodeContext): PatchResult {
|
||||
|
||||
BottomSheetMenuItemBuilderFingerprint.result?.let {
|
||||
it.mutableMethod.apply {
|
||||
val targetIndex = it.scanResult.patternScanResult!!.endIndex
|
||||
val targetRegister = getInstruction<OneRegisterInstruction>(targetIndex).registerA
|
||||
|
||||
val targetParameter = getInstruction<ReferenceInstruction>(targetIndex - 1).reference
|
||||
if (!targetParameter.toString().endsWith("Ljava/lang/CharSequence;"))
|
||||
return PatchResultError("Method signature parameter did not match: $targetParameter")
|
||||
|
||||
addInstructions(
|
||||
targetIndex + 1, """
|
||||
invoke-static {v$targetRegister}, $FLYOUT_PANEL->hideFeedFlyoutPanel(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;
|
||||
move-result-object v$targetRegister
|
||||
"""
|
||||
)
|
||||
}
|
||||
} ?: return BottomSheetMenuItemBuilderFingerprint.toErrorResult()
|
||||
|
||||
/**
|
||||
* Add settings
|
||||
*/
|
||||
SettingsPatch.addPreference(
|
||||
arrayOf(
|
||||
"PREFERENCE: FLYOUT_PANEL_SETTINGS",
|
||||
"SETTINGS: HIDE_FEED_FLYOUT_PANEL"
|
||||
)
|
||||
)
|
||||
|
||||
SettingsPatch.updatePatchStatus("hide-feed-flyout-panel")
|
||||
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user