Quellcode durchsuchen

fix: sharedvolume bug

Sv443 vor 1 Jahr
Ursprung
Commit
092635e009

+ 7 - 7
assets/translations/README.md

@@ -62,7 +62,7 @@ This means to figure out which keys are untranslated, you will need to manually
 | `dev_mode_short` | `Dev` |
 | `advanced_mode_short` | `Advanced` |
 | `feature_category_volume` | `Volume` |
-| `feature_desc_volumeSharedBetweenTabs` | `If the volume level is set in one tab, set it to the same value in others too?` |
+| `feature_desc_volumeSharedBetweenTabs` | `Should the set volume be shared between tabs and remembered between sessions?` |
 | `feature_helptext_volumeSharedBetweenTabs` | `If you change the volume in one tab, the volume level will be set to the same value in all other tabs that have this feature enabled.\nThis value will be remembered and restored across sessions, until disabled.` |
 | `feature_desc_setInitialTabVolume` | `Sets the volume level to a specific value once when opening the site` |
 | `feature_warning_setInitialTabVolume_volumeSharedBetweenTabs_incompatible` | `This feature is incompatible with the "Volume level shared between tabs" feature and will be ignored while using the shared volume feature!` |
@@ -87,7 +87,7 @@ This means to figure out which keys are untranslated, you will need to manually
 | `dev_mode_short` | `Dev` |
 | `advanced_mode_short` | `Advanced` |
 | `feature_category_volume` | `Volume` |
-| `feature_desc_volumeSharedBetweenTabs` | `If the volume level is set in one tab, set it to the same value in others too?` |
+| `feature_desc_volumeSharedBetweenTabs` | `Should the set volume be shared between tabs and remembered between sessions?` |
 | `feature_helptext_volumeSharedBetweenTabs` | `If you change the volume in one tab, the volume level will be set to the same value in all other tabs that have this feature enabled.\nThis value will be remembered and restored across sessions, until disabled.` |
 | `feature_desc_setInitialTabVolume` | `Sets the volume level to a specific value once when opening the site` |
 | `feature_warning_setInitialTabVolume_volumeSharedBetweenTabs_incompatible` | `This feature is incompatible with the "Volume level shared between tabs" feature and will be ignored while using the shared volume feature!` |
@@ -112,7 +112,7 @@ This means to figure out which keys are untranslated, you will need to manually
 | `dev_mode_short` | `Dev` |
 | `advanced_mode_short` | `Advanced` |
 | `feature_category_volume` | `Volume` |
-| `feature_desc_volumeSharedBetweenTabs` | `If the volume level is set in one tab, set it to the same value in others too?` |
+| `feature_desc_volumeSharedBetweenTabs` | `Should the set volume be shared between tabs and remembered between sessions?` |
 | `feature_helptext_volumeSharedBetweenTabs` | `If you change the volume in one tab, the volume level will be set to the same value in all other tabs that have this feature enabled.\nThis value will be remembered and restored across sessions, until disabled.` |
 | `feature_desc_setInitialTabVolume` | `Sets the volume level to a specific value once when opening the site` |
 | `feature_warning_setInitialTabVolume_volumeSharedBetweenTabs_incompatible` | `This feature is incompatible with the "Volume level shared between tabs" feature and will be ignored while using the shared volume feature!` |
@@ -137,7 +137,7 @@ This means to figure out which keys are untranslated, you will need to manually
 | `dev_mode_short` | `Dev` |
 | `advanced_mode_short` | `Advanced` |
 | `feature_category_volume` | `Volume` |
-| `feature_desc_volumeSharedBetweenTabs` | `If the volume level is set in one tab, set it to the same value in others too?` |
+| `feature_desc_volumeSharedBetweenTabs` | `Should the set volume be shared between tabs and remembered between sessions?` |
 | `feature_helptext_volumeSharedBetweenTabs` | `If you change the volume in one tab, the volume level will be set to the same value in all other tabs that have this feature enabled.\nThis value will be remembered and restored across sessions, until disabled.` |
 | `feature_desc_setInitialTabVolume` | `Sets the volume level to a specific value once when opening the site` |
 | `feature_warning_setInitialTabVolume_volumeSharedBetweenTabs_incompatible` | `This feature is incompatible with the "Volume level shared between tabs" feature and will be ignored while using the shared volume feature!` |
@@ -162,7 +162,7 @@ This means to figure out which keys are untranslated, you will need to manually
 | `dev_mode_short` | `Dev` |
 | `advanced_mode_short` | `Advanced` |
 | `feature_category_volume` | `Volume` |
-| `feature_desc_volumeSharedBetweenTabs` | `If the volume level is set in one tab, set it to the same value in others too?` |
+| `feature_desc_volumeSharedBetweenTabs` | `Should the set volume be shared between tabs and remembered between sessions?` |
 | `feature_helptext_volumeSharedBetweenTabs` | `If you change the volume in one tab, the volume level will be set to the same value in all other tabs that have this feature enabled.\nThis value will be remembered and restored across sessions, until disabled.` |
 | `feature_desc_setInitialTabVolume` | `Sets the volume level to a specific value once when opening the site` |
 | `feature_warning_setInitialTabVolume_volumeSharedBetweenTabs_incompatible` | `This feature is incompatible with the "Volume level shared between tabs" feature and will be ignored while using the shared volume feature!` |
@@ -187,7 +187,7 @@ This means to figure out which keys are untranslated, you will need to manually
 | `dev_mode_short` | `Dev` |
 | `advanced_mode_short` | `Advanced` |
 | `feature_category_volume` | `Volume` |
-| `feature_desc_volumeSharedBetweenTabs` | `If the volume level is set in one tab, set it to the same value in others too?` |
+| `feature_desc_volumeSharedBetweenTabs` | `Should the set volume be shared between tabs and remembered between sessions?` |
 | `feature_helptext_volumeSharedBetweenTabs` | `If you change the volume in one tab, the volume level will be set to the same value in all other tabs that have this feature enabled.\nThis value will be remembered and restored across sessions, until disabled.` |
 | `feature_desc_setInitialTabVolume` | `Sets the volume level to a specific value once when opening the site` |
 | `feature_warning_setInitialTabVolume_volumeSharedBetweenTabs_incompatible` | `This feature is incompatible with the "Volume level shared between tabs" feature and will be ignored while using the shared volume feature!` |
@@ -212,7 +212,7 @@ This means to figure out which keys are untranslated, you will need to manually
 | `dev_mode_short` | `Dev` |
 | `advanced_mode_short` | `Advanced` |
 | `feature_category_volume` | `Volume` |
-| `feature_desc_volumeSharedBetweenTabs` | `If the volume level is set in one tab, set it to the same value in others too?` |
+| `feature_desc_volumeSharedBetweenTabs` | `Should the set volume be shared between tabs and remembered between sessions?` |
 | `feature_helptext_volumeSharedBetweenTabs` | `If you change the volume in one tab, the volume level will be set to the same value in all other tabs that have this feature enabled.\nThis value will be remembered and restored across sessions, until disabled.` |
 | `feature_desc_setInitialTabVolume` | `Sets the volume level to a specific value once when opening the site` |
 | `feature_warning_setInitialTabVolume_volumeSharedBetweenTabs_incompatible` | `This feature is incompatible with the "Volume level shared between tabs" feature and will be ignored while using the shared volume feature!` |

+ 1 - 1
assets/translations/en_US.json

@@ -138,7 +138,7 @@
     "feature_desc_volumeSliderStep": "Volume slider sensitivity (by how little percent the volume can be changed at a time)",
     "feature_desc_volumeSliderScrollStep": "Volume slider scroll wheel sensitivity in percent - snaps to the nearest sensitivity value from above",
     "feature_helptext_volumeSliderScrollStep": "By how much percent the volume should be changed when scrolling the volume slider with the mouse wheel.\nThis should be a multiple of the volume slider sensitivity, otherwise there will be small irregular jumps in the volume when scrolling.",
-    "feature_desc_volumeSharedBetweenTabs": "If the volume level is set in one tab, set it to the same value in others too?",
+    "feature_desc_volumeSharedBetweenTabs": "Should the set volume be shared between tabs and remembered between sessions?",
     "feature_helptext_volumeSharedBetweenTabs": "If you change the volume in one tab, the volume level will be set to the same value in all other tabs that have this feature enabled.\nThis value will be remembered and restored across sessions, until disabled.",
     "feature_desc_setInitialTabVolume": "Sets the volume level to a specific value once when opening the site",
     "feature_warning_setInitialTabVolume_volumeSharedBetweenTabs_incompatible": "This feature is incompatible with the \"Volume level shared between tabs\" feature and will be ignored while using the shared volume feature!",

+ 1 - 1
src/features/layout.css

@@ -209,7 +209,7 @@ yt-multi-page-menu-section-renderer.ytd-multi-page-menu-renderer {
   font-size: 1.4rem;
   top: 50%;
   left: 0;
-  transform: translate(calc(-50% - 35px), -50%);
+  transform: translate(calc(-50% - 10px), -50%);
   text-align: right;
   transition: opacity 0.2s ease;
 }

+ 3 - 2
src/features/volume.ts

@@ -162,7 +162,7 @@ function setVolSliderStep(sliderElem: HTMLInputElement) {
 /** Saves the shared volume level to persistent storage */
 async function sharedVolumeChanged(vol: number) {
   try {
-    await GM.setValue("bytm-shared-volume", String(vol));
+    await GM.setValue("bytm-shared-volume", String(lastCheckedSharedVolume = ignoreVal = vol));
   }
   catch(err) {
     error("Couldn't save shared volume level due to an error:", err);
@@ -175,7 +175,6 @@ let lastCheckedSharedVolume = -1;
 async function checkSharedVolume() {
   try {
     const vol = await GM.getValue("bytm-shared-volume");
-    console.log(">checkshared", vol, lastCheckedSharedVolume);
     if(vol && lastCheckedSharedVolume !== Number(vol)) {
       if(ignoreVal === Number(vol))
         return;
@@ -204,6 +203,8 @@ function setInitialTabVolume(sliderElem: HTMLInputElement) {
   const initialVol = getFeatures().initialTabVolumeLevel;
   if(getFeatures().volumeSharedBetweenTabs) {
     lastCheckedSharedVolume = ignoreVal = initialVol;
+    if(getFeatures().volumeSharedBetweenTabs)
+      GM.setValue("bytm-shared-volume", String(initialVol));
   }
   sliderElem.value = String(initialVol);
   sliderElem.dispatchEvent(new Event("change", { bubbles: true }));