Browse Source

fix: copy to clipboard wrapper func

Sv443 11 tháng trước cách đây
mục cha
commit
42e2114eb4

+ 23 - 16
assets/translations/README.md

@@ -20,15 +20,15 @@ To submit or edit a translation, please follow [this guide](../../contributing.m
 ### Translation progress:
 ### Translation progress:
 |   | Locale | Translated keys | Based on |
 |   | Locale | Translated keys | Based on |
 | :----: | ------ | --------------- | :------: |
 | :----: | ------ | --------------- | :------: |
-| ─ | [`en_US`](./en_US.json) | 209 (default locale) |  |
-| ⚠ | [`de_DE`](./de_DE.json) | `204/209` (97.6%) | ─ |
-| ─ | [`en_UK`](./en_UK.json) | `209/209` (100%) | `en_US` |
-| ⚠ | [`es_ES`](./es_ES.json) | `204/209` (97.6%) | ─ |
-| ⚠ | [`fr_FR`](./fr_FR.json) | `204/209` (97.6%) | ─ |
-| ⚠ | [`hi_IN`](./hi_IN.json) | `204/209` (97.6%) | ─ |
-| ⚠ | [`ja_JA`](./ja_JA.json) | `204/209` (97.6%) | ─ |
-| ⚠ | [`pt_BR`](./pt_BR.json) | `204/209` (97.6%) | ─ |
-| ⚠ | [`zh_CN`](./zh_CN.json) | `204/209` (97.6%) | ─ |
+| ─ | [`en_US`](./en_US.json) | 210 (default locale) |  |
+| ⚠ | [`de_DE`](./de_DE.json) | `204/210` (97.1%) | ─ |
+| ─ | [`en_UK`](./en_UK.json) | `210/210` (100%) | `en_US` |
+| ⚠ | [`es_ES`](./es_ES.json) | `204/210` (97.1%) | ─ |
+| ⚠ | [`fr_FR`](./fr_FR.json) | `204/210` (97.1%) | ─ |
+| ⚠ | [`hi_IN`](./hi_IN.json) | `204/210` (97.1%) | ─ |
+| ⚠ | [`ja_JA`](./ja_JA.json) | `204/210` (97.1%) | ─ |
+| ⚠ | [`pt_BR`](./pt_BR.json) | `204/210` (97.1%) | ─ |
+| ⚠ | [`zh_CN`](./zh_CN.json) | `204/210` (97.1%) | ─ |
 
 
 <sub>
 <sub>
 ✅ - Fully translated
 ✅ - Fully translated
@@ -49,10 +49,11 @@ This means to figure out which keys are untranslated, you will need to manually
 
 
 ### Missing keys:
 ### Missing keys:
 
 
-<details><summary><code>de_DE</code> - 5 missing keys <i>(click to show)</i></summary><br>
+<details><summary><code>de_DE</code> - 6 missing keys <i>(click to show)</i></summary><br>
 
 
 | Key | English text |
 | Key | English text |
 | --- | ------------ |
 | --- | ------------ |
+| `copy_to_clipboard_error` | `Couldn't copy the text to the clipboard. Please copy it from here manually:\n%1` |
 | `clear_list` | `Clear the list` |
 | `clear_list` | `Clear the list` |
 | `clear_list_confirm` | `Do you really want to clear the list and leave only the currently playing song?` |
 | `clear_list_confirm` | `Do you really want to clear the list and leave only the currently playing song?` |
 | `feature_desc_fixHdrIssues` | `Fix rendering issues when using an HDR-compatible GPU and monitor` |
 | `feature_desc_fixHdrIssues` | `Fix rendering issues when using an HDR-compatible GPU and monitor` |
@@ -61,10 +62,11 @@ This means to figure out which keys are untranslated, you will need to manually
 
 
 <br></details>
 <br></details>
 
 
-<details><summary><code>es_ES</code> - 5 missing keys <i>(click to show)</i></summary><br>
+<details><summary><code>es_ES</code> - 6 missing keys <i>(click to show)</i></summary><br>
 
 
 | Key | English text |
 | Key | English text |
 | --- | ------------ |
 | --- | ------------ |
+| `copy_to_clipboard_error` | `Couldn't copy the text to the clipboard. Please copy it from here manually:\n%1` |
 | `clear_list` | `Clear the list` |
 | `clear_list` | `Clear the list` |
 | `clear_list_confirm` | `Do you really want to clear the list and leave only the currently playing song?` |
 | `clear_list_confirm` | `Do you really want to clear the list and leave only the currently playing song?` |
 | `feature_desc_fixHdrIssues` | `Fix rendering issues when using an HDR-compatible GPU and monitor` |
 | `feature_desc_fixHdrIssues` | `Fix rendering issues when using an HDR-compatible GPU and monitor` |
@@ -73,10 +75,11 @@ This means to figure out which keys are untranslated, you will need to manually
 
 
 <br></details>
 <br></details>
 
 
-<details><summary><code>fr_FR</code> - 5 missing keys <i>(click to show)</i></summary><br>
+<details><summary><code>fr_FR</code> - 6 missing keys <i>(click to show)</i></summary><br>
 
 
 | Key | English text |
 | Key | English text |
 | --- | ------------ |
 | --- | ------------ |
+| `copy_to_clipboard_error` | `Couldn't copy the text to the clipboard. Please copy it from here manually:\n%1` |
 | `clear_list` | `Clear the list` |
 | `clear_list` | `Clear the list` |
 | `clear_list_confirm` | `Do you really want to clear the list and leave only the currently playing song?` |
 | `clear_list_confirm` | `Do you really want to clear the list and leave only the currently playing song?` |
 | `feature_desc_fixHdrIssues` | `Fix rendering issues when using an HDR-compatible GPU and monitor` |
 | `feature_desc_fixHdrIssues` | `Fix rendering issues when using an HDR-compatible GPU and monitor` |
@@ -85,10 +88,11 @@ This means to figure out which keys are untranslated, you will need to manually
 
 
 <br></details>
 <br></details>
 
 
-<details><summary><code>hi_IN</code> - 5 missing keys <i>(click to show)</i></summary><br>
+<details><summary><code>hi_IN</code> - 6 missing keys <i>(click to show)</i></summary><br>
 
 
 | Key | English text |
 | Key | English text |
 | --- | ------------ |
 | --- | ------------ |
+| `copy_to_clipboard_error` | `Couldn't copy the text to the clipboard. Please copy it from here manually:\n%1` |
 | `clear_list` | `Clear the list` |
 | `clear_list` | `Clear the list` |
 | `clear_list_confirm` | `Do you really want to clear the list and leave only the currently playing song?` |
 | `clear_list_confirm` | `Do you really want to clear the list and leave only the currently playing song?` |
 | `feature_desc_fixHdrIssues` | `Fix rendering issues when using an HDR-compatible GPU and monitor` |
 | `feature_desc_fixHdrIssues` | `Fix rendering issues when using an HDR-compatible GPU and monitor` |
@@ -97,10 +101,11 @@ This means to figure out which keys are untranslated, you will need to manually
 
 
 <br></details>
 <br></details>
 
 
-<details><summary><code>ja_JA</code> - 5 missing keys <i>(click to show)</i></summary><br>
+<details><summary><code>ja_JA</code> - 6 missing keys <i>(click to show)</i></summary><br>
 
 
 | Key | English text |
 | Key | English text |
 | --- | ------------ |
 | --- | ------------ |
+| `copy_to_clipboard_error` | `Couldn't copy the text to the clipboard. Please copy it from here manually:\n%1` |
 | `clear_list` | `Clear the list` |
 | `clear_list` | `Clear the list` |
 | `clear_list_confirm` | `Do you really want to clear the list and leave only the currently playing song?` |
 | `clear_list_confirm` | `Do you really want to clear the list and leave only the currently playing song?` |
 | `feature_desc_fixHdrIssues` | `Fix rendering issues when using an HDR-compatible GPU and monitor` |
 | `feature_desc_fixHdrIssues` | `Fix rendering issues when using an HDR-compatible GPU and monitor` |
@@ -109,10 +114,11 @@ This means to figure out which keys are untranslated, you will need to manually
 
 
 <br></details>
 <br></details>
 
 
-<details><summary><code>pt_BR</code> - 5 missing keys <i>(click to show)</i></summary><br>
+<details><summary><code>pt_BR</code> - 6 missing keys <i>(click to show)</i></summary><br>
 
 
 | Key | English text |
 | Key | English text |
 | --- | ------------ |
 | --- | ------------ |
+| `copy_to_clipboard_error` | `Couldn't copy the text to the clipboard. Please copy it from here manually:\n%1` |
 | `clear_list` | `Clear the list` |
 | `clear_list` | `Clear the list` |
 | `clear_list_confirm` | `Do you really want to clear the list and leave only the currently playing song?` |
 | `clear_list_confirm` | `Do you really want to clear the list and leave only the currently playing song?` |
 | `feature_desc_fixHdrIssues` | `Fix rendering issues when using an HDR-compatible GPU and monitor` |
 | `feature_desc_fixHdrIssues` | `Fix rendering issues when using an HDR-compatible GPU and monitor` |
@@ -121,10 +127,11 @@ This means to figure out which keys are untranslated, you will need to manually
 
 
 <br></details>
 <br></details>
 
 
-<details><summary><code>zh_CN</code> - 5 missing keys <i>(click to show)</i></summary><br>
+<details><summary><code>zh_CN</code> - 6 missing keys <i>(click to show)</i></summary><br>
 
 
 | Key | English text |
 | Key | English text |
 | --- | ------------ |
 | --- | ------------ |
+| `copy_to_clipboard_error` | `Couldn't copy the text to the clipboard. Please copy it from here manually:\n%1` |
 | `clear_list` | `Clear the list` |
 | `clear_list` | `Clear the list` |
 | `clear_list_confirm` | `Do you really want to clear the list and leave only the currently playing song?` |
 | `clear_list_confirm` | `Do you really want to clear the list and leave only the currently playing song?` |
 | `feature_desc_fixHdrIssues` | `Fix rendering issues when using an HDR-compatible GPU and monitor` |
 | `feature_desc_fixHdrIssues` | `Fix rendering issues when using an HDR-compatible GPU and monitor` |

+ 1 - 0
assets/translations/en_US.json

@@ -28,6 +28,7 @@
     "reset_tooltip": "Reset all settings to their default values",
     "reset_tooltip": "Reset all settings to their default values",
     "reset_confirm": "Do you really want to reset all settings to their default values?\nThe page will be automatically reloaded.",
     "reset_confirm": "Do you really want to reset all settings to their default values?\nThe page will be automatically reloaded.",
     "copy_to_clipboard": "Copy to clipboard",
     "copy_to_clipboard": "Copy to clipboard",
+    "copy_to_clipboard_error": "Couldn't copy the text to the clipboard. Please copy it from here manually:\n%1",
     "copy_config_tooltip": "Copy the configuration to your clipboard",
     "copy_config_tooltip": "Copy the configuration to your clipboard",
     "copied": "Copied!",
     "copied": "Copied!",
     "copy_hidden_value": "Copy hidden value",
     "copy_hidden_value": "Copy hidden value",

+ 8 - 8
dist/BetterYTM.css

@@ -1,9 +1,9 @@
 :root {
 :root {
-  --bytm-dialog-accent-col: #3683d4;
-  --bytm-advanced-mode-color: #c5a73b;
-  --bytm-experimental-col: #d07ff0;
-  --bytm-warning-col: #ff5233;
-  --bytm-reload-col: #42b045;
+  --bytm-locale-color: #6a97c7;
+  --bytm-advanced-mode-color: #c5b270;
+  --bytm-experimental-col: #c698d6;
+  --bytm-warning-col: #e07664;
+  --bytm-reload-col: #7ad46a;
 }
 }
 
 
 /* TODO(v1.2): leave only dialog */
 /* TODO(v1.2): leave only dialog */
@@ -86,7 +86,7 @@
 }
 }
 
 
 .bytm-ftitem-adornment svg path {
 .bytm-ftitem-adornment svg path {
-  fill: var(--bytm-dialog-accent-col, #fff) !important;
+  fill: var(--bytm-locale-color, #fff) !important;
 }
 }
 
 
 .bytm-advanced-mode-icon svg path {
 .bytm-advanced-mode-icon svg path {
@@ -583,8 +583,8 @@ hr {
   --toggle-height: 20px;
   --toggle-height: 20px;
   --toggle-width: 40px;
   --toggle-width: 40px;
   --toggle-knob-offset: 4px;
   --toggle-knob-offset: 4px;
-  --toggle-color-on: var(--bytm-dialog-accent-col, #4595c7);
-  --toggle-color-off: #707070;
+  --toggle-color-on: #3683d4;
+  --toggle-color-off: #666;
   --toggle-knob-color: #f5f5f5;
   --toggle-knob-color: #f5f5f5;
 
 
   display: flex;
   display: flex;

+ 6 - 2
src/dialogs/exportCfg.ts

@@ -1,5 +1,5 @@
 import { compress } from "@sv443-network/userutils";
 import { compress } from "@sv443-network/userutils";
-import { compressionSupported, onInteraction, t } from "../utils";
+import { compressionSupported, copyToClipboard, onInteraction, t } from "../utils";
 import { BytmDialog } from "../components";
 import { BytmDialog } from "../components";
 import { compressionFormat, scriptInfo } from "../constants";
 import { compressionFormat, scriptInfo } from "../constants";
 import { formatVersion, getFeatures } from "../config";
 import { formatVersion, getFeatures } from "../config";
@@ -120,7 +120,11 @@ async function renderFooter() {
 
 
   onInteraction(copyBtnElem, async (evt: MouseEvent | KeyboardEvent) => {
   onInteraction(copyBtnElem, async (evt: MouseEvent | KeyboardEvent) => {
     evt?.bubbles && evt.stopPropagation();
     evt?.bubbles && evt.stopPropagation();
-    GM.setClipboard(String(evt?.shiftKey ? lastUncompressedCfgString : await compress(JSON.stringify({ formatVersion, data: getFeatures() }), compressionFormat, "string")));
+    copyToClipboard(
+      evt.shiftKey && lastUncompressedCfgString
+        ? lastUncompressedCfgString
+        : await compress(JSON.stringify({ formatVersion, data: getFeatures() }), compressionFormat, "string")
+    );
     copiedTextElem.style.display = "inline-block";
     copiedTextElem.style.display = "inline-block";
     if(typeof copiedTxtTimeout === "undefined") {
     if(typeof copiedTxtTimeout === "undefined") {
       copiedTxtTimeout = setTimeout(() => {
       copiedTxtTimeout = setTimeout(() => {

+ 3 - 3
src/menu/menu_old.ts

@@ -1,8 +1,8 @@
-import { debounce, isScrollable } from "@sv443-network/userutils";
+import { debounce, isScrollable, type Stringifiable } from "@sv443-network/userutils";
 import { defaultData, getFeatures, setFeatures, setDefaultFeatures } from "../config";
 import { defaultData, getFeatures, setFeatures, setDefaultFeatures } from "../config";
 import { buildNumber, host, mode, scriptInfo } from "../constants";
 import { buildNumber, host, mode, scriptInfo } from "../constants";
 import { featInfo, disableBeforeUnload } from "../features/index";
 import { featInfo, disableBeforeUnload } from "../features/index";
-import { error, getResourceUrl, info, log, resourceToHTMLString, getLocale, hasKey, initTranslations, setLocale, t, arrayWithSeparators, tp, type TrKey, onInteraction, getDomain } from "../utils";
+import { error, getResourceUrl, info, log, resourceToHTMLString, getLocale, hasKey, initTranslations, setLocale, t, arrayWithSeparators, tp, type TrKey, onInteraction, getDomain, copyToClipboard } from "../utils";
 import { siteEvents } from "../siteEvents";
 import { siteEvents } from "../siteEvents";
 import { getChangelogDialog, getExportDialog, getFeatHelpDialog, getImportDialog } from "../dialogs";
 import { getChangelogDialog, getExportDialog, getFeatHelpDialog, getImportDialog } from "../dialogs";
 import type { FeatureCategory, FeatureKey, FeatureConfig, HotkeyObj, FeatureInfo } from "../types";
 import type { FeatureCategory, FeatureKey, FeatureConfig, HotkeyObj, FeatureInfo } from "../types";
@@ -451,7 +451,7 @@ async function addCfgMenu() {
             e.preventDefault();
             e.preventDefault();
             e.stopPropagation();
             e.stopPropagation();
 
 
-            GM.setClipboard(String(getFeatures()[featKey as keyof FeatureConfig]));
+            copyToClipboard(getFeatures()[featKey as keyof FeatureConfig] as Stringifiable);
 
 
             advCopyHintElem.style.display = "inline";
             advCopyHintElem.style.display = "inline";
             if(typeof hiddenCopiedTxtTimeout === "undefined") {
             if(typeof hiddenCopiedTxtTimeout === "undefined") {