mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-05-05 09:04:34 +02:00
feat(youtube): remove hide-stories
patch
This commit is contained in:
parent
bc89e72fba
commit
818629b4dc
@ -1,126 +0,0 @@
|
|||||||
package app.revanced.patches.youtube.general.stories.patch
|
|
||||||
|
|
||||||
import app.revanced.extensions.findMutableMethodOf
|
|
||||||
import app.revanced.extensions.injectHideCall
|
|
||||||
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.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.shared.patch.mapping.ResourceMappingPatch
|
|
||||||
import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility
|
|
||||||
import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch
|
|
||||||
import org.jf.dexlib2.Opcode
|
|
||||||
import org.jf.dexlib2.iface.instruction.formats.Instruction22c
|
|
||||||
import org.jf.dexlib2.iface.instruction.formats.Instruction31i
|
|
||||||
|
|
||||||
@Patch
|
|
||||||
@Name("hide-stories")
|
|
||||||
@Description("Hides YouTube Stories shelf on the feed.")
|
|
||||||
@DependsOn(
|
|
||||||
[
|
|
||||||
ResourceMappingPatch::class,
|
|
||||||
SettingsPatch::class
|
|
||||||
]
|
|
||||||
)
|
|
||||||
@YouTubeCompatibility
|
|
||||||
@Version("0.0.1")
|
|
||||||
class HideStoriesPatch : BytecodePatch() {
|
|
||||||
|
|
||||||
// list of resource names to get the id of
|
|
||||||
private val resourceIds = arrayOf(
|
|
||||||
"reel_multiple_items_shelf",
|
|
||||||
"reel_item_container",
|
|
||||||
"reel_multiple_items_shelf_title_layout"
|
|
||||||
).map { name ->
|
|
||||||
ResourceMappingPatch.resourceMappings.single { it.name == name }.id
|
|
||||||
}
|
|
||||||
private var patchSuccessArray = Array(resourceIds.size) { false }
|
|
||||||
|
|
||||||
override fun execute(context: BytecodeContext): PatchResult {
|
|
||||||
context.classes.forEach { classDef ->
|
|
||||||
classDef.methods.forEach { method ->
|
|
||||||
with(method.implementation) {
|
|
||||||
this?.instructions?.forEachIndexed { index, instruction ->
|
|
||||||
when (instruction.opcode) {
|
|
||||||
Opcode.CONST -> {
|
|
||||||
when ((instruction as Instruction31i).wideLiteral) {
|
|
||||||
resourceIds[0], resourceIds[1] -> {
|
|
||||||
val insertIndex = index + 4
|
|
||||||
val iPutInstruction = instructions.elementAt(insertIndex)
|
|
||||||
if (iPutInstruction.opcode != Opcode.IPUT_OBJECT) return@forEachIndexed
|
|
||||||
|
|
||||||
val mutableMethod =
|
|
||||||
context.proxy(classDef).mutableClass.findMutableMethodOf(
|
|
||||||
method
|
|
||||||
)
|
|
||||||
|
|
||||||
val viewRegister =
|
|
||||||
(iPutInstruction as Instruction22c).registerA
|
|
||||||
mutableMethod.implementation!!.injectHideCall(
|
|
||||||
insertIndex,
|
|
||||||
viewRegister,
|
|
||||||
"layout/GeneralPatch",
|
|
||||||
"hideStoriesShelf"
|
|
||||||
)
|
|
||||||
|
|
||||||
patchSuccessArray[0] = true
|
|
||||||
patchSuccessArray[1] = true
|
|
||||||
}
|
|
||||||
|
|
||||||
resourceIds[2] -> {
|
|
||||||
val insertIndex = index - 1
|
|
||||||
val iPutInstruction = instructions.elementAt(insertIndex)
|
|
||||||
if (iPutInstruction.opcode != Opcode.IPUT_OBJECT) return@forEachIndexed
|
|
||||||
|
|
||||||
val mutableMethod =
|
|
||||||
context.proxy(classDef).mutableClass.findMutableMethodOf(
|
|
||||||
method
|
|
||||||
)
|
|
||||||
|
|
||||||
val viewRegister =
|
|
||||||
(iPutInstruction as Instruction22c).registerA
|
|
||||||
mutableMethod.implementation!!.injectHideCall(
|
|
||||||
insertIndex,
|
|
||||||
viewRegister,
|
|
||||||
"layout/GeneralPatch",
|
|
||||||
"hideStoriesShelf"
|
|
||||||
)
|
|
||||||
|
|
||||||
patchSuccessArray[2] = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
else -> return@forEachIndexed
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
val errorIndex: Int = patchSuccessArray.indexOf(false)
|
|
||||||
|
|
||||||
if (errorIndex == -1) {
|
|
||||||
/*
|
|
||||||
* Add settings
|
|
||||||
*/
|
|
||||||
SettingsPatch.addPreference(
|
|
||||||
arrayOf(
|
|
||||||
"PREFERENCE: GENERAL_SETTINGS",
|
|
||||||
"SETTINGS: HIDE_STORIES_SHELF"
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
SettingsPatch.updatePatchStatus("hide-stories")
|
|
||||||
|
|
||||||
return PatchResultSuccess()
|
|
||||||
} else
|
|
||||||
return PatchResultError("Instruction not found: $errorIndex")
|
|
||||||
}
|
|
||||||
}
|
|
@ -442,9 +442,6 @@ Please do not report any issues you encounter while using this feature."</string
|
|||||||
<string name="revanced_hide_speed_overlay_summary_off">Speed overlay are shown</string>
|
<string name="revanced_hide_speed_overlay_summary_off">Speed overlay are shown</string>
|
||||||
<string name="revanced_hide_speed_overlay_summary_on">Speed overlay are hidden</string>
|
<string name="revanced_hide_speed_overlay_summary_on">Speed overlay are hidden</string>
|
||||||
<string name="revanced_hide_speed_overlay_title">Hide speed overlay</string>
|
<string name="revanced_hide_speed_overlay_title">Hide speed overlay</string>
|
||||||
<string name="revanced_hide_stories_shelf_summary_off">Stories shelves are shown</string>
|
|
||||||
<string name="revanced_hide_stories_shelf_summary_on">Stories shelves are hidden</string>
|
|
||||||
<string name="revanced_hide_stories_shelf_title">Hide stories shelf</string>
|
|
||||||
<string name="revanced_hide_subscriptions_button_summary_off">Subscriptions button is shown</string>
|
<string name="revanced_hide_subscriptions_button_summary_off">Subscriptions button is shown</string>
|
||||||
<string name="revanced_hide_subscriptions_button_summary_on">Subscriptions button is hidden</string>
|
<string name="revanced_hide_subscriptions_button_summary_on">Subscriptions button is hidden</string>
|
||||||
<string name="revanced_hide_subscriptions_button_title">Hide subscriptions button</string>
|
<string name="revanced_hide_subscriptions_button_title">Hide subscriptions button</string>
|
||||||
|
@ -210,9 +210,6 @@
|
|||||||
<!-- SETTINGS: HIDE_SNACK_BAR
|
<!-- SETTINGS: HIDE_SNACK_BAR
|
||||||
<SwitchPreference android:title="@string/revanced_hide_snack_bar_title" android:key="revanced_hide_snack_bar" android:defaultValue="false" android:summaryOn="@string/revanced_hide_snack_bar_summary_on" android:summaryOff="@string/revanced_hide_snack_bar_summary_off" />SETTINGS: HIDE_SNACK_BAR -->
|
<SwitchPreference android:title="@string/revanced_hide_snack_bar_title" android:key="revanced_hide_snack_bar" android:defaultValue="false" android:summaryOn="@string/revanced_hide_snack_bar_summary_on" android:summaryOff="@string/revanced_hide_snack_bar_summary_off" />SETTINGS: HIDE_SNACK_BAR -->
|
||||||
|
|
||||||
<!-- SETTINGS: HIDE_STORIES_SHELF
|
|
||||||
<SwitchPreference android:title="@string/revanced_hide_stories_shelf_title" android:key="revanced_hide_stories_shelf" android:defaultValue="true" android:summaryOn="@string/revanced_hide_stories_shelf_summary_on" android:summaryOff="@string/revanced_hide_stories_shelf_summary_off" />SETTINGS: HIDE_STORIES_SHELF -->
|
|
||||||
|
|
||||||
<!-- SETTINGS: HIDE_SUGGESTIONS_SHELF
|
<!-- SETTINGS: HIDE_SUGGESTIONS_SHELF
|
||||||
<SwitchPreference android:title="@string/revanced_hide_suggestions_shelf_title" android:key="revanced_hide_suggestions_shelf" android:defaultValue="false" android:summaryOn="@string/revanced_hide_suggestions_shelf_summary_on" android:summaryOff="@string/revanced_hide_suggestions_shelf_summary_off" />SETTINGS: HIDE_SUGGESTIONS_SHELF -->
|
<SwitchPreference android:title="@string/revanced_hide_suggestions_shelf_title" android:key="revanced_hide_suggestions_shelf" android:defaultValue="false" android:summaryOn="@string/revanced_hide_suggestions_shelf_summary_on" android:summaryOff="@string/revanced_hide_suggestions_shelf_summary_off" />SETTINGS: HIDE_SUGGESTIONS_SHELF -->
|
||||||
|
|
||||||
@ -334,7 +331,6 @@
|
|||||||
<Preference android:title="hide-mix-playlists" 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-search-terms" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
<Preference android:title="hide-search-terms" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
||||||
<Preference android:title="hide-snack-bar" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
<Preference android:title="hide-snack-bar" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
||||||
<Preference android:title="hide-stories" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
|
||||||
<Preference android:title="hide-suggestions-shelf" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
<Preference android:title="hide-suggestions-shelf" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
||||||
|
|
||||||
<Preference android:title=" " android:selectable="false" android:summary="@string/revanced_misc" />
|
<Preference android:title=" " android:selectable="false" android:summary="@string/revanced_misc" />
|
||||||
|
Loading…
x
Reference in New Issue
Block a user