Sv443 8 месяцев назад
Родитель
Сommit
e516fad64a

+ 44 - 16
assets/translations/README.md

@@ -16,15 +16,15 @@ To submit or edit a translation, please follow [this guide](../../contributing.m
 ### Translation progress:
 |   | Locale | Translated keys | Based on |
 | :----: | ------ | --------------- | :------: |
-| ─ | [`en_US`](./en_US.json) | 278 (default locale) |  |
-| ‼️ | [`de_DE`](./de_DE.json) | `203/278` (73%) | ─ |
-| ─ | [`en_UK`](./en_UK.json) | `278` (100%) | `en_US` |
-| ‼️ | [`es_ES`](./es_ES.json) | `203/278` (73%) | ─ |
-| ‼️ | [`fr_FR`](./fr_FR.json) | `203/278` (73%) | ─ |
-| ‼️ | [`hi_IN`](./hi_IN.json) | `203/278` (73%) | ─ |
-| ‼️ | [`ja_JA`](./ja_JA.json) | `203/278` (73%) | ─ |
-| ‼️ | [`pt_BR`](./pt_BR.json) | `203/278` (73%) | ─ |
-| ‼️ | [`zh_CN`](./zh_CN.json) | `203/278` (73%) | ─ |
+| ─ | [`en_US`](./en_US.json) | 282 (default locale) |  |
+| ‼️ | [`de_DE`](./de_DE.json) | `203/282` (72%) | ─ |
+| ─ | [`en_UK`](./en_UK.json) | `282` (100%) | `en_US` |
+| ‼️ | [`es_ES`](./es_ES.json) | `203/282` (72%) | ─ |
+| ‼️ | [`fr_FR`](./fr_FR.json) | `203/282` (72%) | ─ |
+| ‼️ | [`hi_IN`](./hi_IN.json) | `203/282` (72%) | ─ |
+| ‼️ | [`ja_JA`](./ja_JA.json) | `203/282` (72%) | ─ |
+| ‼️ | [`pt_BR`](./pt_BR.json) | `203/282` (72%) | ─ |
+| ‼️ | [`zh_CN`](./zh_CN.json) | `203/282` (72%) | ─ |
 
 <sub>
 ✅ - Fully translated
@@ -45,7 +45,7 @@ This means to figure out which keys are untranslated, you will need to manually
 
 ### Missing keys:
 
-<details><summary><code>de_DE</code> - 75 missing keys <i>(click to show)</i></summary><br>
+<details><summary><code>de_DE</code> - 79 missing keys <i>(click to show)</i></summary><br>
 
 | Key | English text |
 | --- | ------------ |
@@ -67,6 +67,8 @@ This means to figure out which keys are untranslated, you will need to manually
 | `new_entry_tooltip` | `Click to create a new entry` |
 | `remove_entry` | `Remove this entry` |
 | `edit_entry` | `Edit this entry` |
+| `generic_error_toast` | `Encountered %1` |
+| `error` | `Error` |
 | `open_lyrics_search_prompt` | `Enter the song title and artist to search for the lyrics:` |
 | `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_reset_tooltip` | `Reset to the last saved key combination` |
@@ -119,6 +121,8 @@ This means to figure out which keys are untranslated, you will need to manually
 | `feature_desc_initTimeout` | `How many seconds to wait for features to initialize before considering them to likely be in an errored state` |
 | `feature_helptext_initTimeout` | `This is the amount of time in milliseconds that the script will wait for features to initialize before considering them to likely be in an errored state.\nThis will not affect the script's behavior in a significant way, but if one of your plugins can't initialize in time, you should try increasing this value.` |
 | `feature_desc_toastDuration` | `For how many seconds custom toast notifications should be shown - 0 to disable them entirely` |
+| `feature_desc_showToastOnGenericError` | `Show a notification when an error occurs?` |
+| `feature_helptext_showToastOnGenericError` | `Should an error occur in the script that prevents parts of it from working correctly, a notification will be shown to inform you about it.\nIf you encounter a problem often, please copy the error from the JavaScript console (usually in the F12 menu) and please open an issue on GitHub.` |
 | `feature_desc_resetConfig` | `Reset all settings to their default values` |
 | `feature_btn_resetConfig` | `Reset settings` |
 | `feature_btn_resetConfig_running` | `Confirming...` |
@@ -127,7 +131,7 @@ This means to figure out which keys are untranslated, you will need to manually
 
 <br></details>
 
-<details><summary><code>es_ES</code> - 75 missing keys <i>(click to show)</i></summary><br>
+<details><summary><code>es_ES</code> - 79 missing keys <i>(click to show)</i></summary><br>
 
 | Key | English text |
 | --- | ------------ |
@@ -149,6 +153,8 @@ This means to figure out which keys are untranslated, you will need to manually
 | `new_entry_tooltip` | `Click to create a new entry` |
 | `remove_entry` | `Remove this entry` |
 | `edit_entry` | `Edit this entry` |
+| `generic_error_toast` | `Encountered %1` |
+| `error` | `Error` |
 | `open_lyrics_search_prompt` | `Enter the song title and artist to search for the lyrics:` |
 | `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_reset_tooltip` | `Reset to the last saved key combination` |
@@ -201,6 +207,8 @@ This means to figure out which keys are untranslated, you will need to manually
 | `feature_desc_initTimeout` | `How many seconds to wait for features to initialize before considering them to likely be in an errored state` |
 | `feature_helptext_initTimeout` | `This is the amount of time in milliseconds that the script will wait for features to initialize before considering them to likely be in an errored state.\nThis will not affect the script's behavior in a significant way, but if one of your plugins can't initialize in time, you should try increasing this value.` |
 | `feature_desc_toastDuration` | `For how many seconds custom toast notifications should be shown - 0 to disable them entirely` |
+| `feature_desc_showToastOnGenericError` | `Show a notification when an error occurs?` |
+| `feature_helptext_showToastOnGenericError` | `Should an error occur in the script that prevents parts of it from working correctly, a notification will be shown to inform you about it.\nIf you encounter a problem often, please copy the error from the JavaScript console (usually in the F12 menu) and please open an issue on GitHub.` |
 | `feature_desc_resetConfig` | `Reset all settings to their default values` |
 | `feature_btn_resetConfig` | `Reset settings` |
 | `feature_btn_resetConfig_running` | `Confirming...` |
@@ -209,7 +217,7 @@ This means to figure out which keys are untranslated, you will need to manually
 
 <br></details>
 
-<details><summary><code>fr_FR</code> - 75 missing keys <i>(click to show)</i></summary><br>
+<details><summary><code>fr_FR</code> - 79 missing keys <i>(click to show)</i></summary><br>
 
 | Key | English text |
 | --- | ------------ |
@@ -231,6 +239,8 @@ This means to figure out which keys are untranslated, you will need to manually
 | `new_entry_tooltip` | `Click to create a new entry` |
 | `remove_entry` | `Remove this entry` |
 | `edit_entry` | `Edit this entry` |
+| `generic_error_toast` | `Encountered %1` |
+| `error` | `Error` |
 | `open_lyrics_search_prompt` | `Enter the song title and artist to search for the lyrics:` |
 | `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_reset_tooltip` | `Reset to the last saved key combination` |
@@ -283,6 +293,8 @@ This means to figure out which keys are untranslated, you will need to manually
 | `feature_desc_initTimeout` | `How many seconds to wait for features to initialize before considering them to likely be in an errored state` |
 | `feature_helptext_initTimeout` | `This is the amount of time in milliseconds that the script will wait for features to initialize before considering them to likely be in an errored state.\nThis will not affect the script's behavior in a significant way, but if one of your plugins can't initialize in time, you should try increasing this value.` |
 | `feature_desc_toastDuration` | `For how many seconds custom toast notifications should be shown - 0 to disable them entirely` |
+| `feature_desc_showToastOnGenericError` | `Show a notification when an error occurs?` |
+| `feature_helptext_showToastOnGenericError` | `Should an error occur in the script that prevents parts of it from working correctly, a notification will be shown to inform you about it.\nIf you encounter a problem often, please copy the error from the JavaScript console (usually in the F12 menu) and please open an issue on GitHub.` |
 | `feature_desc_resetConfig` | `Reset all settings to their default values` |
 | `feature_btn_resetConfig` | `Reset settings` |
 | `feature_btn_resetConfig_running` | `Confirming...` |
@@ -291,7 +303,7 @@ This means to figure out which keys are untranslated, you will need to manually
 
 <br></details>
 
-<details><summary><code>hi_IN</code> - 75 missing keys <i>(click to show)</i></summary><br>
+<details><summary><code>hi_IN</code> - 79 missing keys <i>(click to show)</i></summary><br>
 
 | Key | English text |
 | --- | ------------ |
@@ -313,6 +325,8 @@ This means to figure out which keys are untranslated, you will need to manually
 | `new_entry_tooltip` | `Click to create a new entry` |
 | `remove_entry` | `Remove this entry` |
 | `edit_entry` | `Edit this entry` |
+| `generic_error_toast` | `Encountered %1` |
+| `error` | `Error` |
 | `open_lyrics_search_prompt` | `Enter the song title and artist to search for the lyrics:` |
 | `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_reset_tooltip` | `Reset to the last saved key combination` |
@@ -365,6 +379,8 @@ This means to figure out which keys are untranslated, you will need to manually
 | `feature_desc_initTimeout` | `How many seconds to wait for features to initialize before considering them to likely be in an errored state` |
 | `feature_helptext_initTimeout` | `This is the amount of time in milliseconds that the script will wait for features to initialize before considering them to likely be in an errored state.\nThis will not affect the script's behavior in a significant way, but if one of your plugins can't initialize in time, you should try increasing this value.` |
 | `feature_desc_toastDuration` | `For how many seconds custom toast notifications should be shown - 0 to disable them entirely` |
+| `feature_desc_showToastOnGenericError` | `Show a notification when an error occurs?` |
+| `feature_helptext_showToastOnGenericError` | `Should an error occur in the script that prevents parts of it from working correctly, a notification will be shown to inform you about it.\nIf you encounter a problem often, please copy the error from the JavaScript console (usually in the F12 menu) and please open an issue on GitHub.` |
 | `feature_desc_resetConfig` | `Reset all settings to their default values` |
 | `feature_btn_resetConfig` | `Reset settings` |
 | `feature_btn_resetConfig_running` | `Confirming...` |
@@ -373,7 +389,7 @@ This means to figure out which keys are untranslated, you will need to manually
 
 <br></details>
 
-<details><summary><code>ja_JA</code> - 75 missing keys <i>(click to show)</i></summary><br>
+<details><summary><code>ja_JA</code> - 79 missing keys <i>(click to show)</i></summary><br>
 
 | Key | English text |
 | --- | ------------ |
@@ -395,6 +411,8 @@ This means to figure out which keys are untranslated, you will need to manually
 | `new_entry_tooltip` | `Click to create a new entry` |
 | `remove_entry` | `Remove this entry` |
 | `edit_entry` | `Edit this entry` |
+| `generic_error_toast` | `Encountered %1` |
+| `error` | `Error` |
 | `open_lyrics_search_prompt` | `Enter the song title and artist to search for the lyrics:` |
 | `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_reset_tooltip` | `Reset to the last saved key combination` |
@@ -447,6 +465,8 @@ This means to figure out which keys are untranslated, you will need to manually
 | `feature_desc_initTimeout` | `How many seconds to wait for features to initialize before considering them to likely be in an errored state` |
 | `feature_helptext_initTimeout` | `This is the amount of time in milliseconds that the script will wait for features to initialize before considering them to likely be in an errored state.\nThis will not affect the script's behavior in a significant way, but if one of your plugins can't initialize in time, you should try increasing this value.` |
 | `feature_desc_toastDuration` | `For how many seconds custom toast notifications should be shown - 0 to disable them entirely` |
+| `feature_desc_showToastOnGenericError` | `Show a notification when an error occurs?` |
+| `feature_helptext_showToastOnGenericError` | `Should an error occur in the script that prevents parts of it from working correctly, a notification will be shown to inform you about it.\nIf you encounter a problem often, please copy the error from the JavaScript console (usually in the F12 menu) and please open an issue on GitHub.` |
 | `feature_desc_resetConfig` | `Reset all settings to their default values` |
 | `feature_btn_resetConfig` | `Reset settings` |
 | `feature_btn_resetConfig_running` | `Confirming...` |
@@ -455,7 +475,7 @@ This means to figure out which keys are untranslated, you will need to manually
 
 <br></details>
 
-<details><summary><code>pt_BR</code> - 75 missing keys <i>(click to show)</i></summary><br>
+<details><summary><code>pt_BR</code> - 79 missing keys <i>(click to show)</i></summary><br>
 
 | Key | English text |
 | --- | ------------ |
@@ -477,6 +497,8 @@ This means to figure out which keys are untranslated, you will need to manually
 | `new_entry_tooltip` | `Click to create a new entry` |
 | `remove_entry` | `Remove this entry` |
 | `edit_entry` | `Edit this entry` |
+| `generic_error_toast` | `Encountered %1` |
+| `error` | `Error` |
 | `open_lyrics_search_prompt` | `Enter the song title and artist to search for the lyrics:` |
 | `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_reset_tooltip` | `Reset to the last saved key combination` |
@@ -529,6 +551,8 @@ This means to figure out which keys are untranslated, you will need to manually
 | `feature_desc_initTimeout` | `How many seconds to wait for features to initialize before considering them to likely be in an errored state` |
 | `feature_helptext_initTimeout` | `This is the amount of time in milliseconds that the script will wait for features to initialize before considering them to likely be in an errored state.\nThis will not affect the script's behavior in a significant way, but if one of your plugins can't initialize in time, you should try increasing this value.` |
 | `feature_desc_toastDuration` | `For how many seconds custom toast notifications should be shown - 0 to disable them entirely` |
+| `feature_desc_showToastOnGenericError` | `Show a notification when an error occurs?` |
+| `feature_helptext_showToastOnGenericError` | `Should an error occur in the script that prevents parts of it from working correctly, a notification will be shown to inform you about it.\nIf you encounter a problem often, please copy the error from the JavaScript console (usually in the F12 menu) and please open an issue on GitHub.` |
 | `feature_desc_resetConfig` | `Reset all settings to their default values` |
 | `feature_btn_resetConfig` | `Reset settings` |
 | `feature_btn_resetConfig_running` | `Confirming...` |
@@ -537,7 +561,7 @@ This means to figure out which keys are untranslated, you will need to manually
 
 <br></details>
 
-<details><summary><code>zh_CN</code> - 75 missing keys <i>(click to show)</i></summary><br>
+<details><summary><code>zh_CN</code> - 79 missing keys <i>(click to show)</i></summary><br>
 
 | Key | English text |
 | --- | ------------ |
@@ -559,6 +583,8 @@ This means to figure out which keys are untranslated, you will need to manually
 | `new_entry_tooltip` | `Click to create a new entry` |
 | `remove_entry` | `Remove this entry` |
 | `edit_entry` | `Edit this entry` |
+| `generic_error_toast` | `Encountered %1` |
+| `error` | `Error` |
 | `open_lyrics_search_prompt` | `Enter the song title and artist to search for the lyrics:` |
 | `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_reset_tooltip` | `Reset to the last saved key combination` |
@@ -611,6 +637,8 @@ This means to figure out which keys are untranslated, you will need to manually
 | `feature_desc_initTimeout` | `How many seconds to wait for features to initialize before considering them to likely be in an errored state` |
 | `feature_helptext_initTimeout` | `This is the amount of time in milliseconds that the script will wait for features to initialize before considering them to likely be in an errored state.\nThis will not affect the script's behavior in a significant way, but if one of your plugins can't initialize in time, you should try increasing this value.` |
 | `feature_desc_toastDuration` | `For how many seconds custom toast notifications should be shown - 0 to disable them entirely` |
+| `feature_desc_showToastOnGenericError` | `Show a notification when an error occurs?` |
+| `feature_helptext_showToastOnGenericError` | `Should an error occur in the script that prevents parts of it from working correctly, a notification will be shown to inform you about it.\nIf you encounter a problem often, please copy the error from the JavaScript console (usually in the F12 menu) and please open an issue on GitHub.` |
 | `feature_desc_resetConfig` | `Reset all settings to their default values` |
 | `feature_btn_resetConfig` | `Reset settings` |
 | `feature_btn_resetConfig_running` | `Confirming...` |

+ 4 - 0
assets/translations/en_US.json

@@ -71,6 +71,8 @@
     "volume_tooltip": "Volume: %1% (Sensitivity: %2%)",
     "volume_shared_tooltip": "Volume level is shared between tabs - disable in the configuration menu",
     "middle_click_open_tab": "Middle-click to open in a new tab",
+    "generic_error_toast": "Encountered %1",
+    "error": "Error",
     "active_mode_display": "%1 Mode",
     "active_mode_tooltip-1": "The %1 is currently active",
     "active_mode_tooltip-n": "The %1 are currently active",
@@ -270,6 +272,8 @@
     "feature_desc_initTimeout": "How many seconds to wait for features to initialize before considering them to likely be in an errored state",
     "feature_helptext_initTimeout": "This is the amount of time in milliseconds that the script will wait for features to initialize before considering them to likely be in an errored state.\nThis will not affect the script's behavior in a significant way, but if one of your plugins can't initialize in time, you should try increasing this value.",
     "feature_desc_toastDuration": "For how many seconds custom toast notifications should be shown - 0 to disable them entirely",
+    "feature_desc_showToastOnGenericError": "Show a notification when an error occurs?",
+    "feature_helptext_showToastOnGenericError": "Should an error occur in the script that prevents parts of it from working correctly, a notification will be shown to inform you about it.\nIf you encounter a problem often, please copy the error from the JavaScript console (usually in the F12 menu) and please open an issue on GitHub.",
     "feature_desc_resetConfig": "Reset all settings to their default values",
     "feature_btn_resetConfig": "Reset settings",
     "feature_btn_resetConfig_running": "Confirming...",

+ 9 - 2
dist/BetterYTM.css

@@ -3,7 +3,8 @@
   --bytm-locale-color: #5ea2ec;
   --bytm-advanced-mode-color: #ceb663;
   --bytm-experimental-col: #cc83e5;
-  --bytm-warning-col: #e07664;
+  --bytm-warning-col: #e5a63b;
+  --bytm-error-col: #fa5b5b;
   --bytm-reload-col: #77e064;
 }
 
@@ -751,11 +752,17 @@ body .bytm-ripple.slower {
   gap: 10px;
 }
 
-.bytm-toast-icon.img {
+.bytm-toast-icon.img,
+.bytm-toast-icon svg
+{
   width: 24px;
   height: 24px;
 }
 
+.bytm-toast-icon path {
+  fill: var(--toast-icon-fill, #fff);
+}
+
 .bytm-toggle-input-wrapper {
   --toggle-height: 20px;
   --toggle-width: 40px;

+ 4 - 7
src/components/BytmDialog.ts

@@ -1,6 +1,6 @@
 // hoist the class declaration because either rollup or babel is being a hoe
 import { NanoEmitter } from "../utils/NanoEmitter.js";
-import { addStyle, clearInner, getDomain, getResourceUrl, onInteraction, warn } from "../utils/index.js";
+import { clearInner, getDomain, getResourceUrl, onInteraction, warn } from "../utils/index.js";
 import { t } from "../utils/translations.js";
 import { emitInterface } from "../interface.js";
 import "./BytmDialog.css";
@@ -94,6 +94,9 @@ export class BytmDialog extends NanoEmitter<{
     if(this.options.closeOnBgClick)
       bgElem.ariaLabel = bgElem.title = t("close_menu_tooltip");
 
+    bgElem.style.setProperty("--bytm-dialog-width-max", `${this.options.width}px`);
+    bgElem.style.setProperty("--bytm-dialog-height-max", `${this.options.height}px`);
+
     bgElem.style.visibility = "hidden";
     bgElem.style.display = "none";
     bgElem.inert = true;
@@ -103,12 +106,6 @@ export class BytmDialog extends NanoEmitter<{
 
     this.attachListeners(bgElem);
 
-    addStyle(`\
-#bytm-${this.id}-dialog-bg {
-  --bytm-dialog-width-max: ${this.options.width}px;
-  --bytm-dialog-height-max: ${this.options.height}px;
-}`, `dialog-${this.id}-vars`);
-
     this.events.emit("render");
     return bgElem;
   }

+ 2 - 4
src/features/layout.ts

@@ -2,7 +2,7 @@ import { addParent, autoPlural, debounce, fetchAdvanced, pauseFor } from "@sv443
 import { getFeature, getFeatures } from "../config.js";
 import { siteEvents } from "../siteEvents.js";
 import { addSelectorListener } from "../observers.js";
-import { error, getResourceUrl, log, warn, t, onInteraction, openInTab, getBestThumbnailUrl, getDomain, addStyle, currentMediaType, domLoaded, waitVideoElementReady, getVideoTime, fetchCss, addStyleFromResource, fetchVideoVotes, getWatchId, getLocale, tp } from "../utils/index.js";
+import { error, getResourceUrl, log, warn, t, onInteraction, openInTab, getBestThumbnailUrl, getDomain, currentMediaType, domLoaded, waitVideoElementReady, getVideoTime, addStyleFromResource, fetchVideoVotes, getWatchId, getLocale, tp } from "../utils/index.js";
 import { mode, scriptInfo } from "../constants.js";
 import { openCfgMenu } from "../menu/menu_old.js";
 import { createCircularBtn, createRipple } from "../components/index.js";
@@ -184,9 +184,7 @@ export async function addConfigMenuOptionYT(container: HTMLElement) {
 /** Adds anchors around elements and tweaks existing ones so songs are easier to open in a new tab */
 export async function addAnchorImprovements() {
   try {
-    const css = await fetchCss("css-anchor_improvements");
-    if(css)
-      addStyle(css, "anchor-improvements");
+    await addStyleFromResource("css-anchor_improvements");
   }
   catch(err) {
     error("Couldn't add anchor improvements CSS due to an error:", err);