@mfcc64/ytms 18.2.1 → 20.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 +25 -39
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mfcc64/ytms",
3
- "version": "18.2.1",
3
+ "version": "20.0.0",
4
4
  "description": "YouTube Musical Spectrum",
5
5
  "main": "script.mjs",
6
6
  "scripts": {
package/script.mjs CHANGED
@@ -16,7 +16,7 @@
16
16
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
17
  */
18
18
 
19
- import {ShowCQTElement, AutoResumeAudioContext} from "../../showcqt-element@2/showcqt-element.mjs";
19
+ import {ShowCQTElement} from "../../showcqt-element@3/showcqt-element.mjs";
20
20
 
21
21
  (async function(){
22
22
  const get_asset = (name) => String(new URL(`../ytms-assets@1.0.0/${name}`, import.meta.url));
@@ -97,7 +97,7 @@ import {ShowCQTElement, AutoResumeAudioContext} from "../../showcqt-element@2/sh
97
97
  af_links.style.padding = "8px";
98
98
  af_links.style.border = "thin solid white";
99
99
  af_links.style.backgroundColor = "#000000DD";
100
- af_links.style.color = "#FFFFFF";
100
+ af_links.style.color = "#dddddd";
101
101
  af_links.style.fontSize = "10pt";
102
102
  af_links.style.right = "8px";
103
103
  af_links.style.bottom = "calc(var(--ytms-cqt-bottom, 0px) + 8px)";
@@ -115,30 +115,14 @@ import {ShowCQTElement, AutoResumeAudioContext} from "../../showcqt-element@2/sh
115
115
  af_links.attachShadow({mode: "open"}).append(
116
116
  e("style",
117
117
  `:host { opacity: 0; max-width: 700px; }
118
+ a, a:visited { color: #ffffff; font-weight: bold; }
119
+ a:hover { color: #ffffa0; }
118
120
  :host(:hover) { opacity: 1; }
119
121
  img { vertical-align: middle; }`),
120
- e("div", {id: "message"},
121
- e("h3", "YouTube Musical Spectrum"),
122
- e("ul",
123
- e("li", "By default, the visualization is visible on YT Music, Spotify, and SoundCloud but hidden on YouTube page."),
124
- 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."),
125
- e("li", "Click the ", e("img", {alt: "YTMS"}, {src: icon_16}), " icon at the top left corner to open/close settings."),
126
- e("li", "Press ", e("b", "Ctrl+Alt+H"), " to open/close settings and show/hide the ", e("img", {alt: "YTMS"}, {src: icon_16}), " icon."),
127
- e("li", "If you want to change the axis, click it."),
128
- e("li", "If you want to make your change persistent, click ", e("b", "Set as Default Settings"), " button."),
129
- e("li", e("b", "New Features:"), " Custom color, custom range," +
130
- " peak color, bar scale, line visualizer, hue rotation, more color presets, horizontal scroll, coordinate line, peak range."),
131
- e("li", e("a", {href: "https://github.com/mfcc64/youtube-musical-spectrum#settings"}, {target: "_blank"}, "Read more..."))
132
- ),
133
- e("p",
134
- e("button", {id: "close_message"}, {style: "cursor: pointer;"}, "Close"),
135
- " (Click the ", e("img", {alt: "YTMS"}, {src: icon_16}), " icon below to reopen again)"
136
- )
137
- ),
138
122
  e("div", {style: "text-align: right;"},
139
- e("img", {alt: "YTMS"}, {src: icon_16}, {style: "curson: pointer;"}, {id: "open_message"}),
123
+ e("img", {alt: "YTMS"}, {src: icon_16}, {style: "curson: pointer;"}),
140
124
  " Support me on ",
141
- e("a", {href: "https://www.youtube.com/@mfcc64"}, {target: "_blank"}, "Youtube"), " ",
125
+ e("a", {href: "https://www.youtube.com/@mfcc64"}, {target: "_blank"}, "YouTube"), " ",
142
126
  e("a", {href: "https://github.com/mfcc64"}, {target: "_blank"}, "GitHub"), " ",
143
127
  e("a", {href: "https://paypal.me/mfcc64"}, {target: "_blank"}, "PayPal"), " ",
144
128
  e("a", {href: "https://saweria.co/mfcc64"}, {target: "_blank"}, "Saweria")
@@ -157,23 +141,13 @@ import {ShowCQTElement, AutoResumeAudioContext} from "../../showcqt-element@2/sh
157
141
  af_links.style.display = !af_links_timeout || (child_menu.visible?.checked ?? true) ? "block" : "none";
158
142
  }
159
143
 
160
- const message_version = 14;
161
- af_links.shadowRoot.getElementById("message").style.display = get_opt("message_version") == message_version ? "none" : "block";
162
- af_links.shadowRoot.getElementById("close_message").addEventListener("click", function() {
163
- set_opt("message_version", message_version);
164
- af_links.shadowRoot.getElementById("message").style.display = "none";
165
- });
166
- af_links.shadowRoot.getElementById("open_message").addEventListener("click", function() {
167
- af_links.shadowRoot.getElementById("message").style.display = "block";
168
- });
169
-
144
+ const cqt = new ShowCQTElement();
170
145
  let svideos = [];
171
146
  if (document.location.hostname == "soundcloud.com") {
172
- ShowCQTElement.global_audio_context = new AutoResumeAudioContext();
173
147
  const old = AudioContext.prototype.createMediaElementSource;
174
148
  AudioContext.prototype.createMediaElementSource = function(media) {
175
149
  const retval = old.call(this, media);
176
- if (this != ShowCQTElement.global_audio_context) {
150
+ if (this != cqt.audio_context) {
177
151
  console.warn("audio can't connect to showcqt-element");
178
152
  return retval;
179
153
  }
@@ -183,14 +157,13 @@ import {ShowCQTElement, AutoResumeAudioContext} from "../../showcqt-element@2/sh
183
157
  };
184
158
 
185
159
  window.AudioContext = function() {
186
- return ShowCQTElement.global_audio_context;
160
+ return cqt.audio_context;
187
161
  };
188
162
 
189
- Object.setPrototypeOf(window.AudioContext, AutoResumeAudioContext);
190
- window.AudioContext.prototype = AutoResumeAudioContext.prototype;
163
+ Object.setPrototypeOf(window.AudioContext, cqt.audio_context.constructor);
164
+ window.AudioContext.prototype = cqt.audio_context.constructor.prototype;
191
165
  }
192
166
 
193
- var cqt = new ShowCQTElement();
194
167
  set_fixed_style(cqt, 9999999);
195
168
  let stop_count = 0;
196
169
  const videos = document.getElementsByTagName("video");
@@ -810,8 +783,10 @@ import {ShowCQTElement, AutoResumeAudioContext} from "../../showcqt-element@2/sh
810
783
  create_child_checkbox_menu("Transparent", "transparent", (child) => cqt.dataset.opacity = child.checked ? "transparent" : "opaque");
811
784
  create_child_checkbox_menu("Visible", "visible", (child) => {
812
785
  cqt.style.display = child.checked ? "block" : "none";
813
- if (!child.checked)
786
+ if (!child.checked) {
814
787
  coord_line_h.style.display = coord_line_v.style.display = "none";
788
+ cqt.render_clear();
789
+ }
815
790
  update_af_links();
816
791
  });
817
792
 
@@ -944,6 +919,12 @@ import {ShowCQTElement, AutoResumeAudioContext} from "../../showcqt-element@2/sh
944
919
 
945
920
  menu_div.appendChild(menu_table);
946
921
  menu.onclick = function() {
922
+ if (menu_is_hidden && !child_menu.visible.checked) {
923
+ child_menu.visible.checked = true;
924
+ child_menu.visible.onchange();
925
+ return;
926
+ }
927
+
947
928
  menu_is_hidden = !menu_is_hidden;
948
929
  if (menu_is_hidden)
949
930
  menu_div.style.visibility = "hidden";
@@ -951,6 +932,11 @@ import {ShowCQTElement, AutoResumeAudioContext} from "../../showcqt-element@2/sh
951
932
  menu_div.style.visibility = "visible";
952
933
  };
953
934
 
935
+ cqt.addEventListener("dblclick", () => {
936
+ child_menu.visible.checked = false;
937
+ child_menu.visible.onchange();
938
+ });
939
+
954
940
  var hide_menu = !!(get_opt("hide_menu") * 1);
955
941
  menu.style.visibility = hide_menu ? "hidden" : "visible";
956
942
  document.body.insertBefore(menu_div, document.body.firstChild);