瀏覽代碼

fix: auto-fill add/change channel name prompt if channel already exists

Sv443 8 月之前
父節點
當前提交
340759238b
共有 3 個文件被更改,包括 13 次插入34 次删除
  1. 7 7
      assets/translations/README.md
  2. 2 25
      assets/translations/en_US.json
  3. 4 2
      src/dialogs/autoLike.ts

+ 7 - 7
assets/translations/README.md

@@ -79,7 +79,7 @@ This means to figure out which keys are untranslated, you will need to manually
 | `auto_like_button_tooltip_disabled` | `Click to enable auto-liking. Shift-click to open the management dialog.` |
 | `add_auto_like_channel_id_prompt` | `Enter the user ID (@Name / UC...) or full URL of the channel you want to auto-like.\nPress "cancel" to exit.` |
 | `add_auto_like_channel_invalid_id` | `The entered user ID is invalid.\nPlease make sure you copy the entire channel URL! It should contain a part like "channel/UC..." or "/@..."` |
-| `add_auto_like_channel_already_exists_prompt_new_name` | `A channel with that ID is already in the list.\nDo you instead want to change its name?` |
+| `add_auto_like_channel_already_exists_prompt_new_name` | `A channel with that ID is already in the list.\nDo you want to change the name?` |
 | `add_auto_like_channel_name_prompt` | `Enter the name of the channel.\nPress "cancel" to exit.` |
 | `auto_like_channel_edit_name_prompt` | `Enter the new name for this channel.\nPress "cancel" to exit.` |
 | `auto_like_channel_edit_id_prompt` | `Enter the new user ID (@Name / UC...) or full URL for this channel.\nPress "cancel" to exit.` |
@@ -161,7 +161,7 @@ This means to figure out which keys are untranslated, you will need to manually
 | `auto_like_button_tooltip_disabled` | `Click to enable auto-liking. Shift-click to open the management dialog.` |
 | `add_auto_like_channel_id_prompt` | `Enter the user ID (@Name / UC...) or full URL of the channel you want to auto-like.\nPress "cancel" to exit.` |
 | `add_auto_like_channel_invalid_id` | `The entered user ID is invalid.\nPlease make sure you copy the entire channel URL! It should contain a part like "channel/UC..." or "/@..."` |
-| `add_auto_like_channel_already_exists_prompt_new_name` | `A channel with that ID is already in the list.\nDo you instead want to change its name?` |
+| `add_auto_like_channel_already_exists_prompt_new_name` | `A channel with that ID is already in the list.\nDo you want to change the name?` |
 | `add_auto_like_channel_name_prompt` | `Enter the name of the channel.\nPress "cancel" to exit.` |
 | `auto_like_channel_edit_name_prompt` | `Enter the new name for this channel.\nPress "cancel" to exit.` |
 | `auto_like_channel_edit_id_prompt` | `Enter the new user ID (@Name / UC...) or full URL for this channel.\nPress "cancel" to exit.` |
@@ -243,7 +243,7 @@ This means to figure out which keys are untranslated, you will need to manually
 | `auto_like_button_tooltip_disabled` | `Click to enable auto-liking. Shift-click to open the management dialog.` |
 | `add_auto_like_channel_id_prompt` | `Enter the user ID (@Name / UC...) or full URL of the channel you want to auto-like.\nPress "cancel" to exit.` |
 | `add_auto_like_channel_invalid_id` | `The entered user ID is invalid.\nPlease make sure you copy the entire channel URL! It should contain a part like "channel/UC..." or "/@..."` |
-| `add_auto_like_channel_already_exists_prompt_new_name` | `A channel with that ID is already in the list.\nDo you instead want to change its name?` |
+| `add_auto_like_channel_already_exists_prompt_new_name` | `A channel with that ID is already in the list.\nDo you want to change the name?` |
 | `add_auto_like_channel_name_prompt` | `Enter the name of the channel.\nPress "cancel" to exit.` |
 | `auto_like_channel_edit_name_prompt` | `Enter the new name for this channel.\nPress "cancel" to exit.` |
 | `auto_like_channel_edit_id_prompt` | `Enter the new user ID (@Name / UC...) or full URL for this channel.\nPress "cancel" to exit.` |
@@ -325,7 +325,7 @@ This means to figure out which keys are untranslated, you will need to manually
 | `auto_like_button_tooltip_disabled` | `Click to enable auto-liking. Shift-click to open the management dialog.` |
 | `add_auto_like_channel_id_prompt` | `Enter the user ID (@Name / UC...) or full URL of the channel you want to auto-like.\nPress "cancel" to exit.` |
 | `add_auto_like_channel_invalid_id` | `The entered user ID is invalid.\nPlease make sure you copy the entire channel URL! It should contain a part like "channel/UC..." or "/@..."` |
-| `add_auto_like_channel_already_exists_prompt_new_name` | `A channel with that ID is already in the list.\nDo you instead want to change its name?` |
+| `add_auto_like_channel_already_exists_prompt_new_name` | `A channel with that ID is already in the list.\nDo you want to change the name?` |
 | `add_auto_like_channel_name_prompt` | `Enter the name of the channel.\nPress "cancel" to exit.` |
 | `auto_like_channel_edit_name_prompt` | `Enter the new name for this channel.\nPress "cancel" to exit.` |
 | `auto_like_channel_edit_id_prompt` | `Enter the new user ID (@Name / UC...) or full URL for this channel.\nPress "cancel" to exit.` |
@@ -407,7 +407,7 @@ This means to figure out which keys are untranslated, you will need to manually
 | `auto_like_button_tooltip_disabled` | `Click to enable auto-liking. Shift-click to open the management dialog.` |
 | `add_auto_like_channel_id_prompt` | `Enter the user ID (@Name / UC...) or full URL of the channel you want to auto-like.\nPress "cancel" to exit.` |
 | `add_auto_like_channel_invalid_id` | `The entered user ID is invalid.\nPlease make sure you copy the entire channel URL! It should contain a part like "channel/UC..." or "/@..."` |
-| `add_auto_like_channel_already_exists_prompt_new_name` | `A channel with that ID is already in the list.\nDo you instead want to change its name?` |
+| `add_auto_like_channel_already_exists_prompt_new_name` | `A channel with that ID is already in the list.\nDo you want to change the name?` |
 | `add_auto_like_channel_name_prompt` | `Enter the name of the channel.\nPress "cancel" to exit.` |
 | `auto_like_channel_edit_name_prompt` | `Enter the new name for this channel.\nPress "cancel" to exit.` |
 | `auto_like_channel_edit_id_prompt` | `Enter the new user ID (@Name / UC...) or full URL for this channel.\nPress "cancel" to exit.` |
@@ -489,7 +489,7 @@ This means to figure out which keys are untranslated, you will need to manually
 | `auto_like_button_tooltip_disabled` | `Click to enable auto-liking. Shift-click to open the management dialog.` |
 | `add_auto_like_channel_id_prompt` | `Enter the user ID (@Name / UC...) or full URL of the channel you want to auto-like.\nPress "cancel" to exit.` |
 | `add_auto_like_channel_invalid_id` | `The entered user ID is invalid.\nPlease make sure you copy the entire channel URL! It should contain a part like "channel/UC..." or "/@..."` |
-| `add_auto_like_channel_already_exists_prompt_new_name` | `A channel with that ID is already in the list.\nDo you instead want to change its name?` |
+| `add_auto_like_channel_already_exists_prompt_new_name` | `A channel with that ID is already in the list.\nDo you want to change the name?` |
 | `add_auto_like_channel_name_prompt` | `Enter the name of the channel.\nPress "cancel" to exit.` |
 | `auto_like_channel_edit_name_prompt` | `Enter the new name for this channel.\nPress "cancel" to exit.` |
 | `auto_like_channel_edit_id_prompt` | `Enter the new user ID (@Name / UC...) or full URL for this channel.\nPress "cancel" to exit.` |
@@ -571,7 +571,7 @@ This means to figure out which keys are untranslated, you will need to manually
 | `auto_like_button_tooltip_disabled` | `Click to enable auto-liking. Shift-click to open the management dialog.` |
 | `add_auto_like_channel_id_prompt` | `Enter the user ID (@Name / UC...) or full URL of the channel you want to auto-like.\nPress "cancel" to exit.` |
 | `add_auto_like_channel_invalid_id` | `The entered user ID is invalid.\nPlease make sure you copy the entire channel URL! It should contain a part like "channel/UC..." or "/@..."` |
-| `add_auto_like_channel_already_exists_prompt_new_name` | `A channel with that ID is already in the list.\nDo you instead want to change its name?` |
+| `add_auto_like_channel_already_exists_prompt_new_name` | `A channel with that ID is already in the list.\nDo you want to change the name?` |
 | `add_auto_like_channel_name_prompt` | `Enter the name of the channel.\nPress "cancel" to exit.` |
 | `auto_like_channel_edit_name_prompt` | `Enter the new name for this channel.\nPress "cancel" to exit.` |
 | `auto_like_channel_edit_id_prompt` | `Enter the new user ID (@Name / UC...) or full URL for this channel.\nPress "cancel" to exit.` |

+ 2 - 25
assets/translations/en_US.json

@@ -12,7 +12,6 @@
     "reload_tooltip": "Reload the page",
     "feature_requires_reload": "Changing this feature requires a page reload",
     "version_tooltip": "Version %1 (build %2) - click to open the changelog",
-
     "bytm_config_export_import_title": "Export or Import Configuration",
     "bytm_config_import_desc": "Paste the configuration you want to import into the field below, then click the import button:",
     "bytm_config_export_desc": "Copy the following text to export your configuration. Warning: it may contain sensitive data.",
@@ -48,7 +47,6 @@
     "lang_changed_prompt_reload": "The language was changed.\nDo you want to reload the page now to apply changes?",
     "search_placeholder": "Search...",
     "search_clear": "Clear search",
-
     "reset": "Reset",
     "close": "Close",
     "close_tooltip": "Click to close",
@@ -81,7 +79,6 @@
     "advanced_mode": "Advanced mode",
     "advanced_mode_short": "Advanced",
     "experimental_feature": "Experimental feature",
-
     "open_current_lyrics": "Open the current song's lyrics in a new tab",
     "open_lyrics": "Open this song's lyrics in a new tab",
     "open_lyrics_search_prompt": "Enter the song title and artist to search for the lyrics:",
@@ -94,7 +91,6 @@
     "lyrics_clear_cache_confirm_prompt-n": "The lyrics cache currently has %1 entries.\nDo you really want to delete them?",
     "lyrics_clear_cache_success": "Lyrics cache was cleared successfully.",
     "lyrics_cache_changed_clear_confirm": "You have changed settings that affect the data in the lyrics cache, which breaks lyrics URL lookups.\nDo you want to clear the cache now?",
-
     "hotkey_input_click_to_change": "Click to change",
     "hotkey_input_click_to_change_tooltip": "%1 - Currently set to: %2 - Enter any key combination to change. Note: some screen readers might block certain key combinations.",
     "hotkey_input_click_to_cancel_tooltip": "Click to cancel",
@@ -104,7 +100,6 @@
     "hotkey_key_mac_option": "Option",
     "hotkey_key_alt": "Alt",
     "hotkey_key_none": "No hotkey selected",
-
     "welcome_menu_title": "Welcome to %1!",
     "config_menu": "Config Menu",
     "open_config_menu_tooltip": "Click to open the configuration menu",
@@ -116,15 +111,12 @@
     "welcome_text_line_3": "If you like %1, please leave a rating on %2GreasyFork%3 or %4OpenUserJS%5",
     "welcome_text_line_4": "My work relies on donations so please consider %1donating ❤️%2",
     "welcome_text_line_5": "Found a bug or want to suggest a feature? Please %1open an issue on GitHub%2",
-
     "list_button_placement_queue_only": "Currently playing queue only",
     "list_button_placement_everywhere": "In every song list",
-
     "site_selection_both_sites": "Both sites",
     "site_selection_only_yt": "Only YouTube",
     "site_selection_only_ytm": "Only YouTube Music",
     "site_selection_none": "None (disabled)",
-
     "new_version_available": "A new version of %1 is available!\nYou currently have version %2 installed and you can update to version %3",
     "open_update_page_install_manually": "Install on %1",
     "disable_update_check": "Disable automatic update checks",
@@ -134,7 +126,6 @@
     "expand_release_notes": "Click to expand the latest release notes",
     "collapse_release_notes": "Click to collapse the latest release notes",
     "no_updates_found": "No updates found.",
-
     "thumbnail_overlay_behavior_never": "Never",
     "thumbnail_overlay_behavior_videos_only": "Only for videos",
     "thumbnail_overlay_behavior_songs_only": "Only for songs",
@@ -145,7 +136,6 @@
     "thumbnail_overlay_image_fit_crop": "Crop if necessary",
     "thumbnail_overlay_image_fit_full": "Show full image",
     "thumbnail_overlay_image_fit_stretch": "Stretch to fit",
-
     "auto_like_channels_dialog_title": "Auto-liked Channels",
     "auto_like_channels_dialog_desc": "Here you can see what channels you have set to auto-like and you can edit, enable, disable and remove them.\nYou can also manually create entries, though it's easier to just visit the channel page and click the button there.",
     "auto_like": "Auto-like",
@@ -153,7 +143,7 @@
     "auto_like_button_tooltip_disabled": "Click to enable auto-liking. Shift-click to open the management dialog.",
     "add_auto_like_channel_id_prompt": "Enter the user ID (@Name / UC...) or full URL of the channel you want to auto-like.\nPress \"cancel\" to exit.",
     "add_auto_like_channel_invalid_id": "The entered user ID is invalid.\nPlease make sure you copy the entire channel URL! It should contain a part like \"channel/UC...\" or \"/@...\"",
-    "add_auto_like_channel_already_exists_prompt_new_name": "A channel with that ID is already in the list.\nDo you instead want to change its name?",
+    "add_auto_like_channel_already_exists_prompt_new_name": "A channel with that ID is already in the list.\nDo you want to change the name?",
     "add_auto_like_channel_name_prompt": "Enter the name of the channel.\nPress \"cancel\" to exit.",
     "auto_like_channel_edit_name_prompt": "Enter the new name for this channel.\nPress \"cancel\" to exit.",
     "auto_like_channel_edit_id_prompt": "Enter the new user ID (@Name / UC...) or full URL for this channel.\nPress \"cancel\" to exit.",
@@ -165,24 +155,19 @@
     "auto_like_export_import_title": "Export or Import Auto-liked Channels",
     "auto_like_export_desc": "Copy the following text to export your auto-liked channels.",
     "auto_like_import_desc": "Paste the auto-liked channels you want to import into the field below, then click the import button:",
-
     "vote_label_likes-1": "%1 like",
     "vote_label_likes-n": "%1 likes",
     "vote_label_dislikes-1": "%1 dislike",
     "vote_label_dislikes-n": "%1 dislikes",
-
     "vote_ratio_disabled": "Disabled",
     "vote_ratio_green_red": "Green and red",
     "vote_ratio_blue_gray": "Blue and gray",
-
     "votes_format_short": "Shortened",
     "votes_format_long": "Full number",
-
     "unit_entries-1": "entry",
     "unit_entries-n": "entries",
     "unit_days-1": "day",
     "unit_days-n": "days",
-
     "feature_category_layout": "Layout",
     "feature_category_volume": "Volume",
     "feature_category_songLists": "Song Lists",
@@ -190,7 +175,6 @@
     "feature_category_input": "Input",
     "feature_category_lyrics": "Lyrics",
     "feature_category_general": "General",
-
     "feature_desc_watermarkEnabled": "Show a watermark under the site logo that opens this config menu",
     "feature_helptext_watermarkEnabled": "If this is disabled, you can still open the config menu by clicking the option in the menu that opens when you click your profile picture in the top right corner.\nHowever it will be harder to find the easter egg ;)",
     "feature_desc_removeShareTrackingParam": "Remove the tracking parameter \"?si\" from the URL in share menus",
@@ -199,7 +183,6 @@
     "feature_desc_numKeysSkipToTime": "Enable skipping to a specific time in the video by pressing a number key (0-9)",
     "feature_desc_fixSpacing": "Fix spacing issues in the layout",
     "feature_helptext_fixSpacing": "There are various locations in the user interface where the spacing between elements is inconsistent. This feature fixes those issues.",
-
     "feature_desc_volumeSliderLabel": "Add a percentage label next to the volume slider",
     "feature_desc_volumeSliderSize": "The width of the volume slider in pixels",
     "feature_desc_volumeSliderStep": "Volume slider sensitivity (by how little percent the volume can be changed at a time)",
@@ -225,14 +208,12 @@
     "feature_desc_showVotes": "Show the amount of likes and dislikes on the currently playing song",
     "feature_helptext_showVotes": "This feature is powered by Return YouTube Dislike and will show the approximate amount of likes and dislikes on the currently playing song.",
     "feature_desc_showVotesFormat": "How should the likes and dislikes be formatted?",
-
     "feature_desc_lyricsQueueButton": "Add a button to each song in a list to open its lyrics page",
     "feature_desc_deleteFromQueueButton": "Add a button to each song in a list to quickly remove it",
     "feature_desc_listButtonsPlacement": "Where should the list buttons show up?",
     "feature_helptext_listButtonsPlacement": "There are various song lists on the site like album pages, playlists and the currently playing queue.\nWith this option you can choose where the list buttons should show up.",
     "feature_desc_scrollToActiveSongBtn": "Add a button above the queue to scroll to the currently playing song",
     "feature_desc_clearQueueBtn": "Add a button above the currently playing queue or playlist to quickly clear it",
-
     "feature_desc_disableBeforeUnloadPopup": "Prevent the confirmation popup that appears when trying to leave the site while a song is playing",
     "feature_helptext_disableBeforeUnloadPopup": "When trying to leave the site while a few seconds into a song that is actively playing, a popup will appear asking you to confirm that you want to leave the site. It might say something along the lines of \"you have unsaved data\" or \"this site is asking if you want to close it\".\nThis feature disables that popup entirely.",
     "feature_desc_closeToastsTimeout": "After how many seconds to close permanent notifications - 0 to only close them manually (default behavior)",
@@ -245,7 +226,6 @@
     "feature_desc_rememberSongTimeReduction": "How many seconds to subtract when restoring the time of a remembered song",
     "feature_helptext_rememberSongTimeReduction": "When restoring the time of a song that was remembered, this amount of seconds will be subtracted from the remembered time so you have more context when listening to the part that was interrupted again.",
     "feature_desc_rememberSongTimeMinPlayTime": "Minimum amount of seconds a song needs to be played for its time to be remembered",
-
     "feature_desc_arrowKeySupport": "Use arrow keys to skip forwards and backwards in the currently playing song",
     "feature_helptext_arrowKeySupport": "Normally you can only skip forwards and backwards by a fixed 10 second interval with the keys \"H\" and \"L\". This feature allows you to use the arrow keys too.\nTo change the amount of seconds to skip, use the option below.",
     "feature_desc_arrowKeySkipBy": "By how many seconds to skip when using the arrow keys",
@@ -263,7 +243,6 @@
     "feature_desc_autoLikeOpenMgmtDialog": "Open the dialog to manage auto-liked channels",
     "feature_btn_autoLikeOpenMgmtDialog": "Open dialog",
     "feature_btn_autoLikeOpenMgmtDialog_running": "Opening...",
-
     "feature_desc_geniusLyrics": "Add a button to the media controls of the currently playing song to open its lyrics on genius.com",
     "feature_desc_geniUrlBase": "Base URL of your geniURL instance, see https://github.com/Sv443/geniURL",
     "feature_helptext_geniUrlBase": "If you have your own instance of geniURL running (for example to bypass rate limiting), you can enter its base URL here to use it for the genius.com lyrics button.\nIf you don't know what this is, you can leave this option as is.",
@@ -279,7 +258,6 @@
     "feature_btn_clearLyricsCache_running": "Clearing...",
     "feature_desc_advancedLyricsFilter": "Experimental: Enable advanced filtering for the lyrics search",
     "feature_helptext_advancedLyricsFilter": "Advanced filtering includes multiple layers of filters that aim to make the lyrics lookups more reliable.\nThese filters may not work well for songs in your language, and songs and artists with less unique titles in general.\nWarning: This feature is still experimental and might not actually perform any better than the default lyrics lookup. Make sure to confirm the prompt that appears if you changed this setting.",
-
     "feature_desc_locale": "Language",
     "feature_desc_localeFallback": "Use English as a fallback for missing translations (disable if you are contributing translations)",
     "feature_desc_versionCheck": "Check for updates every 24 hours",
@@ -297,9 +275,8 @@
     "feature_btn_resetConfig_running": "Confirming...",
     "feature_desc_advancedMode": "Show advanced settings (reloads the menu)",
     "feature_helptext_advancedMode": "After enabling this, the menu will reload and show advanced settings that are hidden by default.\nThis is useful if you want to more deeply customize the script's behavior and don't care about an overcrowded menu.",
-
     "plugin_validation_error_no_property": "No property '%1' with type '%2'",
     "plugin_validation_error_invalid_property-1": "Property '%1' with value '%2' is invalid. Example value: %3",
     "plugin_validation_error_invalid_property-n": "Property '%1' with value '%2' is invalid. Example values: %3"
   }
-}
+}

+ 4 - 2
src/dialogs/autoLike.ts

@@ -296,13 +296,15 @@ async function addAutoLikeEntryPrompts() {
 
   let overwriteName = false;
 
-  if(autoLikeStore.getData().channels.some((ch) => ch.id === id)) {
+  const hasChannelEntry = autoLikeStore.getData().channels.find((ch) => ch.id === id);
+
+  if(hasChannelEntry) {
     if(!confirm(t("add_auto_like_channel_already_exists_prompt_new_name")))
       return;
     overwriteName = true;
   }
 
-  const name = prompt(t("add_auto_like_channel_name_prompt"))?.trim();
+  const name = prompt(t("add_auto_like_channel_name_prompt"), hasChannelEntry?.name)?.trim();
   if(!name || name.length === 0)
     return;