@mfcc64/ytms 10.2.2 → 11.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/script.mjs +21 -8
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mfcc64/ytms",
3
- "version": "10.2.2",
3
+ "version": "11.0.0",
4
4
  "description": "YouTube Musical Spectrum",
5
5
  "main": "script.mjs",
6
6
  "scripts": {
package/script.mjs CHANGED
@@ -43,7 +43,8 @@ import {ShowCQTElement} from "../../showcqt-element@2/showcqt-element.mjs";
43
43
  interval: { def: 1, min: 1, max: 4 },
44
44
  codecs: { def: 1, min: 0, max: 2 },
45
45
  transparent:{ def: 1, min: 0, max: 1 },
46
- visible: { def: 1, min: 0, max: 1 },
46
+ visible: { def: document.location.hostname == "music.youtube.com" ? 1 : 0,
47
+ min: 0, max: 1 },
47
48
  axis: { def: 0, min: 0, max: axis_list.length - 1 }
48
49
  };
49
50
 
@@ -90,12 +91,11 @@ import {ShowCQTElement} from "../../showcqt-element@2/showcqt-element.mjs";
90
91
  af_links.style.right = "8px";
91
92
  af_links.style.bottom = "8px";
92
93
  af_links.style.opacity = 1;
93
- af_links.style.display = "none";
94
94
  {
95
95
  const e = (name, ...args) => {
96
96
  const v = document.createElement(name);
97
97
  for (const arg of args)
98
- if (typeof arg == "object" && !(arg instanceof Object.getPrototypeOf(HTMLDivElement)))
98
+ if (typeof arg == "object" && !(arg instanceof Node))
99
99
  v.setAttribute(...Object.entries(arg)[0])
100
100
  else
101
101
  v.append(arg);
@@ -109,9 +109,10 @@ import {ShowCQTElement} from "../../showcqt-element@2/showcqt-element.mjs";
109
109
  e("div", {id: "message"},
110
110
  e("h3", "YouTube Musical Spectrum"),
111
111
  e("ul",
112
- e("li", "Click the, ", e("img", {alt: "YTMS"}, {src: icon_16}), " icon at the top left corner to open/close settings."),
112
+ e("li", "By default, the visualization is visible on YT Music page but hidden on YouTube page."),
113
+ e("li", "Click the ", e("img", {alt: "YTMS"}, {src: icon_16}), " icon at the top left corner to open/close settings."),
113
114
  e("li", "Press ", e("b", "Ctrl+Alt+H"), " to open/close settings and show/hide the ", e("img", {alt: "YTMS"}, {src: icon_16}), " icon."),
114
- e("li", "Press ", e("b", "Ctrl+Alt+G"), " as a shortcut to show/hide visualization."),
115
+ e("li", "Press ", e("b", "Ctrl+Alt+G"), " as a shortcut to show/hide visualization. This is equivalent to check/uncheck ", e("b", "Visible"), " setting."),
115
116
  e("li", "If you want to change the axis, click it."),
116
117
  e("li", "If you want to make your change persistent, click ", e("b", "Set as Default Settings"), " button."),
117
118
  e("li", e("b", "New Features:"), " Hz-scale axis, microphone support, YT Music support, scale options to " +
@@ -135,9 +136,18 @@ import {ShowCQTElement} from "../../showcqt-element@2/showcqt-element.mjs";
135
136
  );
136
137
  }
137
138
 
138
- setTimeout(() => af_links.style.opacity = "", 15000);
139
+ let af_links_timeout = false;
140
+ setTimeout(() => {
141
+ af_links.style.opacity = "";
142
+ af_links_timeout = true,
143
+ update_af_links();
144
+ }, 15000);
139
145
 
140
- const message_version = 7;
146
+ function update_af_links() {
147
+ af_links.style.display = !af_links_timeout || (child_menu.visible?.checked ?? true) ? "block" : "none";
148
+ }
149
+
150
+ const message_version = 8;
141
151
  af_links.shadowRoot.getElementById("message").style.display = get_opt("message_version") == message_version ? "none" : "block";
142
152
  af_links.shadowRoot.getElementById("close_message").addEventListener("click", function() {
143
153
  set_opt("message_version", message_version);
@@ -473,7 +483,10 @@ import {ShowCQTElement} from "../../showcqt-element@2/showcqt-element.mjs";
473
483
  }
474
484
 
475
485
  create_child_checkbox_menu("Transparent", "transparent", (child) => cqt.dataset.opacity = child.checked ? "transparent" : "opaque");
476
- create_child_checkbox_menu("Visible", "visible", (child) => af_links.style.display = cqt.style.display = child.checked ? "block" : "none");
486
+ create_child_checkbox_menu("Visible", "visible", (child) => {
487
+ cqt.style.display = child.checked ? "block" : "none";
488
+ update_af_links();
489
+ });
477
490
 
478
491
  current_tr = null;
479
492
  set_common_tr_style(get_menu_table_tr());