mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-06-12 05:07:41 +02:00
feat(YouTube/YT Music): add Return YouTube Username
patch
This commit is contained in:
@ -139,6 +139,7 @@ object VisualPreferencesIconsPatch : BaseResourcePatch(
|
||||
"revanced_preference_screen_settings",
|
||||
"revanced_preference_screen_video",
|
||||
"revanced_preference_screen_ryd",
|
||||
"revanced_preference_screen_return_youtube_username",
|
||||
"revanced_preference_screen_sb",
|
||||
"revanced_preference_screen_misc",
|
||||
)
|
||||
|
@ -0,0 +1,40 @@
|
||||
package app.revanced.patches.music.utils.returnyoutubeusername
|
||||
|
||||
import app.revanced.patcher.data.BytecodeContext
|
||||
import app.revanced.patches.music.utils.compatibility.Constants.COMPATIBLE_PACKAGE
|
||||
import app.revanced.patches.music.utils.settings.CategoryType
|
||||
import app.revanced.patches.music.utils.settings.SettingsPatch
|
||||
import app.revanced.patches.shared.returnyoutubeusername.BaseReturnYouTubeUsernamePatch
|
||||
import app.revanced.util.patch.BaseBytecodePatch
|
||||
|
||||
@Suppress("unused")
|
||||
object ReturnYouTubeUsernamePatch : BaseBytecodePatch(
|
||||
name = "Return YouTube Username",
|
||||
description = "Adds option to replace YouTube Handle with Username in comments using YouTube Data API v3.",
|
||||
dependencies = setOf(
|
||||
BaseReturnYouTubeUsernamePatch::class,
|
||||
SettingsPatch::class,
|
||||
),
|
||||
compatiblePackages = COMPATIBLE_PACKAGE,
|
||||
use = false
|
||||
) {
|
||||
override fun execute(context: BytecodeContext) {
|
||||
|
||||
SettingsPatch.addSwitchPreference(
|
||||
CategoryType.RETURN_YOUTUBE_USERNAME,
|
||||
"revanced_return_youtube_username_enabled",
|
||||
"false"
|
||||
)
|
||||
SettingsPatch.addPreferenceWithIntent(
|
||||
CategoryType.RETURN_YOUTUBE_USERNAME,
|
||||
"revanced_return_youtube_username_youtube_data_api_v3_developer_key",
|
||||
"revanced_return_youtube_username_enabled"
|
||||
)
|
||||
if (SettingsPatch.upward0627) {
|
||||
SettingsPatch.addPreferenceWithIntent(
|
||||
CategoryType.RETURN_YOUTUBE_USERNAME,
|
||||
"revanced_return_youtube_username_youtube_data_api_v3_about"
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
@ -11,6 +11,7 @@ enum class CategoryType(val value: String, var added: Boolean) {
|
||||
SETTINGS("settings", false),
|
||||
VIDEO("video", false),
|
||||
RETURN_YOUTUBE_DISLIKE("ryd", false),
|
||||
RETURN_YOUTUBE_USERNAME("return_youtube_username", false),
|
||||
SPONSOR_BLOCK("sb", false),
|
||||
MISC("misc", false)
|
||||
}
|
@ -6,6 +6,7 @@ object Constants {
|
||||
const val PATCHES_PATH = "$INTEGRATIONS_PATH/patches"
|
||||
const val COMPONENTS_PATH = "$PATCHES_PATH/components"
|
||||
|
||||
const val INTEGRATIONS_UTILS_PATH = "$INTEGRATIONS_PATH/utils"
|
||||
const val INTEGRATIONS_SETTING_CLASS_DESCRIPTOR = "$INTEGRATIONS_PATH/settings/Setting;"
|
||||
const val INTEGRATIONS_UTILS_CLASS_DESCRIPTOR = "$INTEGRATIONS_PATH/utils/Utils;"
|
||||
const val INTEGRATIONS_UTILS_CLASS_DESCRIPTOR = "$INTEGRATIONS_UTILS_PATH/Utils;"
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package app.revanced.patches.shared.returnyoutubeusername
|
||||
|
||||
import app.revanced.patcher.data.BytecodeContext
|
||||
import app.revanced.patcher.patch.BytecodePatch
|
||||
import app.revanced.patcher.patch.annotation.Patch
|
||||
import app.revanced.patches.shared.integrations.Constants.PATCHES_PATH
|
||||
import app.revanced.patches.shared.textcomponent.TextComponentPatch
|
||||
|
||||
@Patch(dependencies = [TextComponentPatch::class])
|
||||
object BaseReturnYouTubeUsernamePatch : BytecodePatch(emptySet()) {
|
||||
private const val INTEGRATIONS_CLASS_DESCRIPTOR =
|
||||
"$PATCHES_PATH/ReturnYouTubeUsernamePatch;"
|
||||
|
||||
override fun execute(context: BytecodeContext) {
|
||||
TextComponentPatch.hookSpannableString(INTEGRATIONS_CLASS_DESCRIPTOR, "preFetchLithoText")
|
||||
TextComponentPatch.hookTextComponent(INTEGRATIONS_CLASS_DESCRIPTOR)
|
||||
}
|
||||
}
|
||||
|
@ -195,6 +195,7 @@ object VisualPreferencesIconsPatch : BaseResourcePatch(
|
||||
"revanced_preference_screen_swipe_controls",
|
||||
"revanced_preference_screen_video",
|
||||
"revanced_preference_screen_ryd",
|
||||
"revanced_preference_screen_return_youtube_username",
|
||||
"revanced_preference_screen_sb",
|
||||
"revanced_preference_screen_misc",
|
||||
)
|
||||
|
@ -0,0 +1,34 @@
|
||||
package app.revanced.patches.youtube.utils.returnyoutubeusername
|
||||
|
||||
import app.revanced.patcher.data.BytecodeContext
|
||||
import app.revanced.patches.shared.returnyoutubeusername.BaseReturnYouTubeUsernamePatch
|
||||
import app.revanced.patches.youtube.utils.compatibility.Constants.COMPATIBLE_PACKAGE
|
||||
import app.revanced.patches.youtube.utils.settings.SettingsPatch
|
||||
import app.revanced.util.patch.BaseBytecodePatch
|
||||
|
||||
@Suppress("unused")
|
||||
object ReturnYouTubeUsernamePatch : BaseBytecodePatch(
|
||||
name = "Return YouTube Username",
|
||||
description = "Adds option to replace YouTube Handle with Username in comments using YouTube Data API v3.",
|
||||
dependencies = setOf(
|
||||
BaseReturnYouTubeUsernamePatch::class,
|
||||
SettingsPatch::class,
|
||||
),
|
||||
compatiblePackages = COMPATIBLE_PACKAGE,
|
||||
use = false
|
||||
) {
|
||||
override fun execute(context: BytecodeContext) {
|
||||
|
||||
/**
|
||||
* Add settings
|
||||
*/
|
||||
SettingsPatch.addPreference(
|
||||
arrayOf(
|
||||
"PREFERENCE_SCREEN: RETURN_YOUTUBE_USERNAME"
|
||||
)
|
||||
)
|
||||
|
||||
SettingsPatch.updatePatchStatus(this)
|
||||
|
||||
}
|
||||
}
|
@ -8,8 +8,8 @@ import app.revanced.patcher.patch.BytecodePatch
|
||||
import app.revanced.patcher.patch.annotation.Patch
|
||||
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
|
||||
import app.revanced.patches.shared.integrations.Constants.INTEGRATIONS_UTILS_CLASS_DESCRIPTOR
|
||||
import app.revanced.patches.shared.integrations.Constants.INTEGRATIONS_UTILS_PATH
|
||||
import app.revanced.patches.shared.mapping.ResourceMappingPatch
|
||||
import app.revanced.patches.youtube.utils.integrations.Constants.INTEGRATIONS_PATH
|
||||
import app.revanced.patches.youtube.utils.integrations.Constants.UTILS_PATH
|
||||
import app.revanced.patches.youtube.utils.mainactivity.MainActivityResolvePatch
|
||||
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch
|
||||
@ -31,7 +31,7 @@ object SettingsBytecodePatch : BytecodePatch(
|
||||
"$UTILS_PATH/InitializationPatch;"
|
||||
|
||||
private const val INTEGRATIONS_THEME_METHOD_DESCRIPTOR =
|
||||
"$INTEGRATIONS_PATH/utils/ThemeUtils;->setTheme(Ljava/lang/Enum;)V"
|
||||
"$INTEGRATIONS_UTILS_PATH/BaseThemeUtils;->setTheme(Ljava/lang/Enum;)V"
|
||||
|
||||
internal lateinit var contexts: BytecodeContext
|
||||
|
||||
|
Reference in New Issue
Block a user