diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/general/loadmorebutton/fingerprints/LoadMoreButtonFingerprint.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/general/loadmorebutton/fingerprints/LoadMoreButtonFingerprint.kt
new file mode 100644
index 000000000..e392c6bf1
--- /dev/null
+++ b/src/main/kotlin/app/revanced/patches/youtube/layout/general/loadmorebutton/fingerprints/LoadMoreButtonFingerprint.kt
@@ -0,0 +1,21 @@
+package app.revanced.patches.youtube.layout.general.loadmorebutton.fingerprints
+
+import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
+import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch
+import org.jf.dexlib2.Opcode
+import org.jf.dexlib2.iface.instruction.WideLiteralInstruction
+
+object LoadMoreButtonFingerprint : MethodFingerprint(
+ opcodes = listOf(
+ Opcode.CONST,
+ Opcode.CONST_4,
+ Opcode.INVOKE_STATIC,
+ Opcode.MOVE_RESULT_OBJECT
+ ),
+ customFingerprint = { methodDef ->
+ methodDef.implementation?.instructions?.any { instruction ->
+ instruction.opcode.ordinal == Opcode.CONST.ordinal &&
+ (instruction as? WideLiteralInstruction)?.wideLiteral == SharedResourceIdPatch.expandButtonId
+ } == true
+ }
+)
\ No newline at end of file
diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/general/loadmorebutton/patch/LoadMoreButtonPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/general/loadmorebutton/patch/LoadMoreButtonPatch.kt
new file mode 100644
index 000000000..7ff0dac67
--- /dev/null
+++ b/src/main/kotlin/app/revanced/patches/youtube/layout/general/loadmorebutton/patch/LoadMoreButtonPatch.kt
@@ -0,0 +1,64 @@
+package app.revanced.patches.youtube.layout.general.loadmorebutton.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.addInstruction
+import app.revanced.patcher.extensions.instruction
+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.shared.annotation.YouTubeCompatibility
+import app.revanced.patches.youtube.layout.general.loadmorebutton.fingerprints.LoadMoreButtonFingerprint
+import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch
+import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch
+import app.revanced.util.integrations.Constants.GENERAL
+import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
+
+@Patch
+@Name("hide-load-more-button")
+@Description("Hides the button under videos that loads similar videos.")
+@DependsOn(
+ [
+ SettingsPatch::class,
+ SharedResourceIdPatch::class,
+ ]
+)
+@YouTubeCompatibility
+@Version("0.0.1")
+class LoadMoreButtonPatch : BytecodePatch(
+ listOf(
+ LoadMoreButtonFingerprint,
+ )
+) {
+ override fun execute(context: BytecodeContext): PatchResult {
+ LoadMoreButtonFingerprint.result?.let {
+ it.mutableMethod.apply {
+ val targetIndex = it.scanResult.patternScanResult!!.endIndex
+ val targetRegister = (instruction(targetIndex) as OneRegisterInstruction).registerA
+ addInstruction(
+ targetIndex + 1,
+ "invoke-static {v$targetRegister}, $GENERAL->hideLoadMoreButton(Landroid/view/View;)V"
+ )
+ }
+ }?: return LoadMoreButtonFingerprint.toErrorResult()
+
+ /**
+ * Add settings
+ */
+ SettingsPatch.addPreference(
+ arrayOf(
+ "PREFERENCE: GENERAL_SETTINGS",
+ "SETTINGS: HIDE_LOAD_MORE_BUTTON"
+ )
+ )
+
+ SettingsPatch.updatePatchStatus("hide-load-more-button")
+
+ return PatchResultSuccess()
+ }
+}
diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/settings/resource/patch/SettingsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/settings/resource/patch/SettingsPatch.kt
index 4bc258d06..2fac4c3d8 100644
--- a/src/main/kotlin/app/revanced/patches/youtube/misc/settings/resource/patch/SettingsPatch.kt
+++ b/src/main/kotlin/app/revanced/patches/youtube/misc/settings/resource/patch/SettingsPatch.kt
@@ -125,7 +125,7 @@ class SettingsPatch : AbstractSettingsResourcePatch(
return PatchResultSuccess()
}
companion object {
- private lateinit var contexts: ResourceContext
+ internal lateinit var contexts: ResourceContext
internal fun addPreference(settingArray: Array) {
contexts.addPreference(settingArray)
diff --git a/src/main/resources/youtube/settings/host/values/strings.xml b/src/main/resources/youtube/settings/host/values/strings.xml
index 48a4b2e3a..b3e659d50 100644
--- a/src/main/resources/youtube/settings/host/values/strings.xml
+++ b/src/main/resources/youtube/settings/host/values/strings.xml
@@ -316,6 +316,9 @@ Please do not report any issues you encounter while using this feature."Library button is shown
Library button is hidden
Hide library button
+ Load more button is shown
+ Load more button is hidden
+ Hide load more button
Navigation label is shown
Navigation label is hidden
Hide navigation label
diff --git a/src/main/resources/youtube/settings/xml/revanced_prefs.xml b/src/main/resources/youtube/settings/xml/revanced_prefs.xml
index 56e879893..6ac9276bc 100644
--- a/src/main/resources/youtube/settings/xml/revanced_prefs.xml
+++ b/src/main/resources/youtube/settings/xml/revanced_prefs.xml
@@ -141,6 +141,9 @@
+
+
@@ -482,6 +485,7 @@
+