diff --git a/src/main/kotlin/app/revanced/patches/music/layout/visual/VisualPreferencesIconsPatch.kt b/src/main/kotlin/app/revanced/patches/music/layout/visual/VisualPreferencesIconsPatch.kt
index c7969c38a5..1306f0c3f0 100644
--- a/src/main/kotlin/app/revanced/patches/music/layout/visual/VisualPreferencesIconsPatch.kt
+++ b/src/main/kotlin/app/revanced/patches/music/layout/visual/VisualPreferencesIconsPatch.kt
@@ -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",
)
diff --git a/src/main/kotlin/app/revanced/patches/music/utils/returnyoutubeusername/ReturnYouTubeUsernamePatch.kt b/src/main/kotlin/app/revanced/patches/music/utils/returnyoutubeusername/ReturnYouTubeUsernamePatch.kt
new file mode 100644
index 0000000000..442f28a1fa
--- /dev/null
+++ b/src/main/kotlin/app/revanced/patches/music/utils/returnyoutubeusername/ReturnYouTubeUsernamePatch.kt
@@ -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"
+ )
+ }
+ }
+}
diff --git a/src/main/kotlin/app/revanced/patches/music/utils/settings/CategoryType.kt b/src/main/kotlin/app/revanced/patches/music/utils/settings/CategoryType.kt
index 4219f5ba33..875ccfa44f 100644
--- a/src/main/kotlin/app/revanced/patches/music/utils/settings/CategoryType.kt
+++ b/src/main/kotlin/app/revanced/patches/music/utils/settings/CategoryType.kt
@@ -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)
}
\ No newline at end of file
diff --git a/src/main/kotlin/app/revanced/patches/shared/integrations/Constants.kt b/src/main/kotlin/app/revanced/patches/shared/integrations/Constants.kt
index 59d7f47aeb..03c2e3fe8f 100644
--- a/src/main/kotlin/app/revanced/patches/shared/integrations/Constants.kt
+++ b/src/main/kotlin/app/revanced/patches/shared/integrations/Constants.kt
@@ -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;"
}
\ No newline at end of file
diff --git a/src/main/kotlin/app/revanced/patches/shared/returnyoutubeusername/BaseReturnYouTubeUsernamePatch.kt b/src/main/kotlin/app/revanced/patches/shared/returnyoutubeusername/BaseReturnYouTubeUsernamePatch.kt
new file mode 100644
index 0000000000..daf5814dd2
--- /dev/null
+++ b/src/main/kotlin/app/revanced/patches/shared/returnyoutubeusername/BaseReturnYouTubeUsernamePatch.kt
@@ -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)
+ }
+}
+
diff --git a/src/main/kotlin/app/revanced/patches/youtube/layout/visual/VisualPreferencesIconsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/layout/visual/VisualPreferencesIconsPatch.kt
index 39ba1eddd9..46a2abeb25 100644
--- a/src/main/kotlin/app/revanced/patches/youtube/layout/visual/VisualPreferencesIconsPatch.kt
+++ b/src/main/kotlin/app/revanced/patches/youtube/layout/visual/VisualPreferencesIconsPatch.kt
@@ -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",
)
diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/returnyoutubeusername/ReturnYouTubeUsernamePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/returnyoutubeusername/ReturnYouTubeUsernamePatch.kt
new file mode 100644
index 0000000000..6f0cca8806
--- /dev/null
+++ b/src/main/kotlin/app/revanced/patches/youtube/utils/returnyoutubeusername/ReturnYouTubeUsernamePatch.kt
@@ -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)
+
+ }
+}
diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/settings/SettingsBytecodePatch.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/settings/SettingsBytecodePatch.kt
index d4625b195e..e46e4a1236 100644
--- a/src/main/kotlin/app/revanced/patches/youtube/utils/settings/SettingsBytecodePatch.kt
+++ b/src/main/kotlin/app/revanced/patches/youtube/utils/settings/SettingsBytecodePatch.kt
@@ -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
diff --git a/src/main/resources/music/settings/host/values/strings.xml b/src/main/resources/music/settings/host/values/strings.xml
index bd037e0e1b..ef7bbb9c25 100644
--- a/src/main/resources/music/settings/host/values/strings.xml
+++ b/src/main/resources/music/settings/host/values/strings.xml
@@ -318,6 +318,23 @@ Some features may not work properly in the old player layout."
Hidden
+
+ Return YouTube Username
+
+ Enable Return YouTube Username
+ Show Username instead of Handle in comments.
+ YouTube Data API key
+ The developer key for using the YouTube Data API v3.
+ About YouTube Data API key
+ "YouTube Data API v3 Developer Key is required to replace Handle with Username.
+
+The daily quota for API keys on the free plan is 10,000, and 1 quota is used to replace Handle with Username for 1 comment.
+
+Click to see how to issue a API key."
+ Issue YouTube Data API v3 developer key
+ 1. Go to <a href=%1$s>Create a new project</a>.<br>2. Click the <b>CREATE</b> button.<br>3. Go to <a href=%2$s>YouTube Data API v3</a>.<br>4. Click the <b>ENABLE</b> button.<br>5. Click the <b>CREATE CREDENTIALS</b> button.<br>6. Select the <b>Public data</b> option.<br>7. Click the <b>NEXT</b> button.<br>8. Copy the API key.<br><br>※ API key should never be shared with others, so it is not included in Import / Export settings.
+
+
SponsorBlock
diff --git a/src/main/resources/music/visual/shared/drawable/revanced_preference_screen_return_youtube_username_icon.xml b/src/main/resources/music/visual/shared/drawable/revanced_preference_screen_return_youtube_username_icon.xml
new file mode 100644
index 0000000000..44d1ed65a0
--- /dev/null
+++ b/src/main/resources/music/visual/shared/drawable/revanced_preference_screen_return_youtube_username_icon.xml
@@ -0,0 +1,18 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/src/main/resources/youtube/settings/host/values/strings.xml b/src/main/resources/youtube/settings/host/values/strings.xml
index 709c7bf0d8..98023d30f6 100644
--- a/src/main/resources/youtube/settings/host/values/strings.xml
+++ b/src/main/resources/youtube/settings/host/values/strings.xml
@@ -1483,6 +1483,23 @@ Limitation: Dislikes may not appear if the user is not logged in or in incognito
Hidden
+
+ Return YouTube Username
+
+ Enable Return YouTube Username
+ Username is used.
+ Handle is used.
+ YouTube Data API key
+ The developer key for using the YouTube Data API v3.
+ About YouTube Data API key
+ "YouTube Data API v3 Developer Key is required to replace Handle with Username.
+
+The daily quota for API keys on the free plan is 10,000, and 1 quota is used to replace Handle with Username for 1 comment.
+
+Click to see how to issue a API key."
+ Issue YouTube Data API v3 developer key
+ 1. Go to <a href=%1$s>Create a new project</a>.<br>2. Click the <b>CREATE</b> button.<br>3. Go to <a href=%2$s>YouTube Data API v3</a>.<br>4. Click the <b>ENABLE</b> button.<br>5. Click the <b>CREATE CREDENTIALS</b> button.<br>6. Select the <b>Public data</b> option.<br>7. Click the <b>NEXT</b> button.<br>8. Copy the API key.<br><br>※ API key should never be shared with others, so it is not included in Import / Export settings.
+
SponsorBlock
diff --git a/src/main/resources/youtube/settings/xml/revanced_prefs.xml b/src/main/resources/youtube/settings/xml/revanced_prefs.xml
index 64b6997793..d971fb4875 100644
--- a/src/main/resources/youtube/settings/xml/revanced_prefs.xml
+++ b/src/main/resources/youtube/settings/xml/revanced_prefs.xml
@@ -664,6 +664,14 @@
PREFERENCE_SCREEN: RETURN_YOUTUBE_DISLIKE -->
+
+
+