feat(youtube): add hide-description-components patch

This commit is contained in:
inotia00
2023-07-03 19:36:56 +09:00
parent 93d1c57390
commit 8f4695763e
3 changed files with 68 additions and 2 deletions

View File

@ -0,0 +1,49 @@
package app.revanced.patches.youtube.descriptions.layout.patch
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.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.youtube.utils.annotations.YouTubeCompatibility
import app.revanced.patches.youtube.utils.litho.patch.LithoFilterPatch
import app.revanced.patches.youtube.utils.settings.resource.patch.SettingsPatch
import app.revanced.util.bytecode.BytecodeHelper.updatePatchStatus
import app.revanced.util.integrations.Constants.PATCHES_PATH
@Patch
@Name("hide-description-components")
@Description("Hides description components.")
@DependsOn(
[
LithoFilterPatch::class,
SettingsPatch::class
]
)
@YouTubeCompatibility
@Version("0.0.1")
class DescriptionComponentsPatch : BytecodePatch() {
override fun execute(context: BytecodeContext): PatchResult {
LithoFilterPatch.addFilter("$PATCHES_PATH/ads/DescriptionsFilter;")
/**
* Add settings
*/
SettingsPatch.addPreference(
arrayOf(
"PREFERENCE: GENERAL_SETTINGS",
"SETTINGS: HIDE_DESCRIPTION_COMPONENTS"
)
)
SettingsPatch.updatePatchStatus("hide-description-components")
context.updatePatchStatus("DescriptionComponent")
return PatchResultSuccess()
}
}