mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-04-30 14:44:30 +02:00
feat(youtube): add hide-latest-videos-button
patch
This commit is contained in:
parent
350e51691c
commit
ab663b8820
@ -0,0 +1,21 @@
|
||||
package app.revanced.patches.youtube.general.latestvideosbutton.fingerprints
|
||||
|
||||
import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch.Companion.Bar
|
||||
import app.revanced.util.bytecode.isWideLiteralExists
|
||||
import com.android.tools.smali.dexlib2.AccessFlags
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
|
||||
object LatestVideosButtonFingerprint : MethodFingerprint(
|
||||
returnType = "V",
|
||||
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||
parameters = listOf("L", "Z"),
|
||||
opcodes = listOf(
|
||||
Opcode.CONST,
|
||||
Opcode.IGET_OBJECT,
|
||||
Opcode.INVOKE_VIRTUAL,
|
||||
Opcode.MOVE_RESULT_OBJECT
|
||||
),
|
||||
customFingerprint = { methodDef, _ -> methodDef.isWideLiteralExists(Bar) }
|
||||
)
|
@ -0,0 +1,63 @@
|
||||
package app.revanced.patches.youtube.general.latestvideosbutton.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.addInstruction
|
||||
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.general.latestvideosbutton.fingerprints.LatestVideosButtonFingerprint
|
||||
import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility
|
||||
import app.revanced.patches.youtube.utils.resourceid.patch.SharedResourceIdPatch
|
||||
import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch
|
||||
import app.revanced.util.integrations.Constants.GENERAL
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
||||
|
||||
@Patch
|
||||
@Name("Hide latest videos button")
|
||||
@Description("Hides latest videos button in home feed.")
|
||||
@DependsOn(
|
||||
[
|
||||
SettingsPatch::class,
|
||||
SharedResourceIdPatch::class,
|
||||
]
|
||||
)
|
||||
@YouTubeCompatibility
|
||||
@Version("0.0.1")
|
||||
class LatestVideosButtonPatch : BytecodePatch(
|
||||
listOf(LatestVideosButtonFingerprint)
|
||||
) {
|
||||
override fun execute(context: BytecodeContext): PatchResult {
|
||||
LatestVideosButtonFingerprint.result?.let {
|
||||
it.mutableMethod.apply {
|
||||
val targetIndex = it.scanResult.patternScanResult!!.endIndex
|
||||
val targetRegister = getInstruction<OneRegisterInstruction>(targetIndex).registerA
|
||||
|
||||
addInstruction(
|
||||
targetIndex + 1,
|
||||
"invoke-static {v$targetRegister}, $GENERAL->hideLatestVideosButton(Landroid/view/View;)V"
|
||||
)
|
||||
}
|
||||
} ?: return LatestVideosButtonFingerprint.toErrorResult()
|
||||
|
||||
/**
|
||||
* Add settings
|
||||
*/
|
||||
SettingsPatch.addPreference(
|
||||
arrayOf(
|
||||
"PREFERENCE: GENERAL_SETTINGS",
|
||||
"SETTINGS: HIDE_LATEST_VIDEOS_BUTTON"
|
||||
)
|
||||
)
|
||||
|
||||
SettingsPatch.updatePatchStatus("hide-latest-videos-button")
|
||||
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
}
|
@ -28,6 +28,7 @@ class SharedResourceIdPatch : ResourcePatch {
|
||||
var AutoNavPreviewStub: Long = -1
|
||||
var AutoNavToggle: Long = -1
|
||||
var BackgroundCategory: Long = -1
|
||||
var Bar: Long = -1
|
||||
var BarContainerHeight: Long = -1
|
||||
var BottomPanelOverlayText: Long = -1
|
||||
var BottomSheetMargins: Long = -1
|
||||
@ -101,6 +102,7 @@ class SharedResourceIdPatch : ResourcePatch {
|
||||
AutoNavPreviewStub = find(ID, "autonav_preview_stub")
|
||||
AutoNavToggle = find(ID, "autonav_toggle")
|
||||
BackgroundCategory = find(STRING, "pref_background_and_offline_category")
|
||||
Bar = find(LAYOUT, "bar")
|
||||
BarContainerHeight = find(DIMEN, "bar_container_height")
|
||||
BottomPanelOverlayText = find(ID, "bottom_panel_overlay_text")
|
||||
BottomSheetMargins = find(DIMEN, "bottom_sheet_margins")
|
||||
|
@ -338,6 +338,9 @@
|
||||
<string name="revanced_hide_library_button_summary_off">Library button is shown</string>
|
||||
<string name="revanced_hide_library_button_summary_on">Library button is hidden</string>
|
||||
<string name="revanced_hide_library_button_title">Hide library button</string>
|
||||
<string name="revanced_hide_latest_videos_button_summary_off">Latest videos button is shown</string>
|
||||
<string name="revanced_hide_latest_videos_button_summary_on">Latest videos button is hidden</string>
|
||||
<string name="revanced_hide_latest_videos_button_title">Hide latest videos button</string>
|
||||
<string name="revanced_hide_load_more_button_summary_off">Load more button is shown</string>
|
||||
<string name="revanced_hide_load_more_button_summary_on">Load more button is hidden</string>
|
||||
<string name="revanced_hide_load_more_button_title">Hide load more button</string>
|
||||
|
@ -169,6 +169,9 @@
|
||||
<!-- SETTINGS: HIDE_FLOATING_MICROPHONE
|
||||
<SwitchPreference android:title="@string/revanced_hide_floating_microphone_title" android:key="revanced_hide_floating_microphone" android:defaultValue="true" android:summaryOn="@string/revanced_hide_floating_microphone_summary_on" android:summaryOff="@string/revanced_hide_floating_microphone_summary_off" />SETTINGS: HIDE_FLOATING_MICROPHONE -->
|
||||
|
||||
<!-- SETTINGS: HIDE_LATEST_VIDEOS_BUTTON
|
||||
<SwitchPreference android:title="@string/revanced_hide_latest_videos_button_title" android:key="revanced_hide_latest_videos_button" android:defaultValue="true" android:summaryOn="@string/revanced_hide_latest_videos_button_summary_on" android:summaryOff="@string/revanced_hide_latest_videos_button_summary_off" />SETTINGS: HIDE_LATEST_VIDEOS_BUTTON -->
|
||||
|
||||
<!-- SETTINGS: HIDE_LOAD_MORE_BUTTON
|
||||
<SwitchPreference android:title="@string/revanced_hide_load_more_button_title" android:key="revanced_hide_load_more_button" android:defaultValue="true" android:summaryOn="@string/revanced_hide_load_more_button_summary_on" android:summaryOff="@string/revanced_hide_load_more_button_summary_off" />SETTINGS: HIDE_LOAD_MORE_BUTTON -->
|
||||
|
||||
@ -326,6 +329,7 @@
|
||||
<Preference android:title="hide-email-address" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
||||
<Preference android:title="hide-floating-microphone" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
||||
<Preference android:title="hide-layout-components" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
||||
<Preference android:title="hide-latest-videos-button" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
||||
<Preference android:title="hide-load-more-button" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
||||
<Preference android:title="hide-mix-playlists" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
||||
<Preference android:title="hide-snack-bar" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
||||
|
Loading…
x
Reference in New Issue
Block a user