mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-05-12 04:24:36 +02:00
feat(YouTube/YT Music): add Return YouTube Username
patch
This commit is contained in:
parent
504998f326
commit
9733b6090d
@ -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
|
||||
|
||||
|
@ -318,6 +318,23 @@ Some features may not work properly in the old player layout."</string>
|
||||
<string name="revanced_ryd_video_likes_hidden_by_video_owner">Hidden</string>
|
||||
|
||||
|
||||
<!-- PreferenceScreen: Return YouTube Username -->
|
||||
<string name="revanced_preference_screen_return_youtube_username_title">Return YouTube Username</string>
|
||||
|
||||
<string name="revanced_return_youtube_username_enabled_title">Enable Return YouTube Username</string>
|
||||
<string name="revanced_return_youtube_username_enabled_summary">Show Username instead of Handle in comments.</string>
|
||||
<string name="revanced_return_youtube_username_youtube_data_api_v3_developer_key_title">YouTube Data API key</string>
|
||||
<string name="revanced_return_youtube_username_youtube_data_api_v3_developer_key_summary">The developer key for using the YouTube Data API v3.</string>
|
||||
<string name="revanced_return_youtube_username_youtube_data_api_v3_about_title">About YouTube Data API key</string>
|
||||
<string name="revanced_return_youtube_username_youtube_data_api_v3_about_summary">"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."</string>
|
||||
<string name="revanced_return_youtube_username_youtube_data_api_v3_dialog_title">Issue YouTube Data API v3 developer key</string>
|
||||
<string name="revanced_return_youtube_username_youtube_data_api_v3_dialog_message">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.</string>
|
||||
|
||||
|
||||
<!-- PreferenceScreen: SponsorBlock -->
|
||||
<string name="revanced_preference_screen_sb_title">SponsorBlock</string>
|
||||
|
||||
|
@ -0,0 +1,18 @@
|
||||
<vector
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:name="vector"
|
||||
android:width="48dp"
|
||||
android:height="48dp"
|
||||
android:viewportWidth="960"
|
||||
android:viewportHeight="960">
|
||||
<group
|
||||
android:scaleX="0.5"
|
||||
android:scaleY="0.5"
|
||||
android:pivotX="300"
|
||||
android:pivotY="480">
|
||||
<path
|
||||
android:name="path"
|
||||
android:pathData="M 349.504 315.587 L 610.497 315.587 L 610.497 368.835 L 349.504 368.835 L 349.504 315.587 Z M 755.994 135.465 L 755.994 824.535 L 584.287 652.829 L 204.007 652.829 L 204.007 135.465 L 755.994 135.465 Z M 236.631 169.09 L 236.631 621.204 L 236.631 620.204 L 597.654 620.204 L 597.947 620.497 L 607.403 629.952 L 721.662 744.211 L 723.369 745.918 L 725.076 747.625 L 723.369 745.918 L 723.369 748.332 L 723.369 167.09 L 723.369 168.09 L 237.631 168.09 M 349.504 454.083 L 506.624 454.083 L 506.624 507.332 L 349.504 507.332 L 349.504 454.083 Z"
|
||||
android:fillColor="@android:color/white" />
|
||||
</group>
|
||||
</vector>
|
@ -1483,6 +1483,23 @@ Limitation: Dislikes may not appear if the user is not logged in or in incognito
|
||||
<string name="revanced_ryd_video_likes_hidden_by_video_owner">Hidden</string>
|
||||
|
||||
|
||||
<!-- PreferenceScreen: Return YouTube Username -->
|
||||
<string name="revanced_preference_screen_return_youtube_username_title">Return YouTube Username</string>
|
||||
|
||||
<string name="revanced_return_youtube_username_enabled_title">Enable Return YouTube Username</string>
|
||||
<string name="revanced_return_youtube_username_enabled_summary_on">Username is used.</string>
|
||||
<string name="revanced_return_youtube_username_enabled_summary_off">Handle is used.</string>
|
||||
<string name="revanced_return_youtube_username_youtube_data_api_v3_developer_key_title">YouTube Data API key</string>
|
||||
<string name="revanced_return_youtube_username_youtube_data_api_v3_developer_key_summary">The developer key for using the YouTube Data API v3.</string>
|
||||
<string name="revanced_return_youtube_username_youtube_data_api_v3_about_title">About YouTube Data API key</string>
|
||||
<string name="revanced_return_youtube_username_youtube_data_api_v3_about_summary">"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."</string>
|
||||
<string name="revanced_return_youtube_username_youtube_data_api_v3_dialog_title">Issue YouTube Data API v3 developer key</string>
|
||||
<string name="revanced_return_youtube_username_youtube_data_api_v3_dialog_message">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.</string>
|
||||
|
||||
<!-- PreferenceScreen: SponsorBlock -->
|
||||
<string name="revanced_preference_screen_sb_title">SponsorBlock</string>
|
||||
|
||||
|
@ -664,6 +664,14 @@
|
||||
</PreferenceScreen>PREFERENCE_SCREEN: RETURN_YOUTUBE_DISLIKE -->
|
||||
|
||||
|
||||
<!-- PREFERENCE_SCREEN: RETURN_YOUTUBE_USERNAME
|
||||
<PreferenceScreen android:title="@string/revanced_preference_screen_return_youtube_username_title" android:key="revanced_preference_screen_return_youtube_username" >
|
||||
<SwitchPreference android:title="@string/revanced_return_youtube_username_enabled_title" android:key="revanced_return_youtube_username_enabled" android:summaryOn="@string/revanced_return_youtube_username_enabled_summary_on" android:summaryOff="@string/revanced_return_youtube_username_enabled_summary_off" />
|
||||
<app.revanced.integrations.shared.settings.preference.ResettableEditTextPreference android:title="@string/revanced_return_youtube_username_youtube_data_api_v3_developer_key_title" android:key="revanced_return_youtube_username_youtube_data_api_v3_developer_key" android:summary="@string/revanced_return_youtube_username_youtube_data_api_v3_developer_key_summary" android:dependency="revanced_return_youtube_username_enabled" />
|
||||
<app.revanced.integrations.youtube.settings.preference.AboutYouTubeDataAPIPreference android:title="@string/revanced_return_youtube_username_youtube_data_api_v3_about_title" android:summary="@string/revanced_return_youtube_username_youtube_data_api_v3_about_summary" />
|
||||
</PreferenceScreen>PREFERENCE_SCREEN: RETURN_YOUTUBE_USERNAME -->
|
||||
|
||||
|
||||
<!-- PREFERENCE_SCREEN: SPONSOR_BLOCK
|
||||
<PreferenceScreen android:title="@string/revanced_preference_screen_sb_title" android:key="revanced_preference_screen_sb" >
|
||||
<SwitchPreference android:title="@string/revanced_sb_enable_sb" android:key="sb_enabled" android:summary="@string/revanced_sb_enable_sb_sum" />
|
||||
@ -852,6 +860,7 @@
|
||||
<Preference android:title="Icon" android:summary="@string/revanced_icon_default" android:selectable="false"/>
|
||||
<Preference android:title="Label" android:summary="@string/revanced_label_default" android:selectable="false"/>
|
||||
<Preference android:title="Return YouTube Dislike" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
||||
<Preference android:title="Return YouTube Username" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
||||
<Preference android:title="SponsorBlock" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
||||
<Preference android:title="Theme" android:summary="@string/revanced_theme_default" android:selectable="false"/>
|
||||
<Preference android:title="Translations" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
||||
|
@ -0,0 +1,18 @@
|
||||
<vector
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:name="vector"
|
||||
android:width="48dp"
|
||||
android:height="48dp"
|
||||
android:viewportWidth="960"
|
||||
android:viewportHeight="960">
|
||||
<group
|
||||
android:scaleX="0.5"
|
||||
android:scaleY="0.5"
|
||||
android:pivotX="480"
|
||||
android:pivotY="480">
|
||||
<path
|
||||
android:name="path"
|
||||
android:pathData="M 840 803.077 L 716.923 680 L 175.384 680 Q 152.327 680 136.163 663.837 Q 120 647.673 120 624.616 L 120 175.384 Q 120 152.327 136.163 136.163 Q 152.327 120 175.384 120 L 784.616 120 Q 807.673 120 823.837 136.163 Q 840 152.327 840 175.384 L 840 803.077 Z M 175.384 649.231 L 730.615 649.231 L 809.231 730.769 L 809.231 175.384 Q 809.231 166.154 801.539 158.461 Q 793.846 150.769 784.616 150.769 L 175.384 150.769 Q 166.154 150.769 158.461 158.461 Q 150.769 166.154 150.769 175.384 L 150.769 624.616 Q 150.769 633.846 158.461 641.539 Q 166.154 649.231 175.384 649.231 Z M 150.769 649.231 L 150.769 150.769 L 150.769 649.231 Z"
|
||||
android:fillColor="?ytTextPrimary" />
|
||||
</group>
|
||||
</vector>
|
Loading…
x
Reference in New Issue
Block a user