@mfcc64/ytms 20.0.2 → 21.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 +34 -69
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mfcc64/ytms",
3
- "version": "20.0.2",
3
+ "version": "21.0.0",
4
4
  "description": "YouTube Musical Spectrum",
5
5
  "main": "script.mjs",
6
6
  "scripts": {
package/script.mjs CHANGED
@@ -19,10 +19,10 @@
19
19
  import {ShowCQTElement} from "../../showcqt-element@3/showcqt-element.mjs";
20
20
 
21
21
  (async function(){
22
- const get_asset = (name) => String(new URL(`../ytms-assets@1.0.0/${name}`, import.meta.url));
22
+ const get_asset = (name) => String(new URL(`../ytms-assets@2.0.0/${name}`, import.meta.url));
23
23
  const axis_list = [
24
- "",
25
- get_asset("axis-hz-1920x32.png")
24
+ [ "", get_asset("axis-1920x32-flip.png") ],
25
+ [ get_asset("axis-hz-1920x32.png"), get_asset("axis-hz-1920x32-flip.png") ]
26
26
  ];
27
27
 
28
28
  const defaults = {
@@ -40,7 +40,7 @@ import {ShowCQTElement} from "../../showcqt-element@3/showcqt-element.mjs";
40
40
  bar_scale: { def: 0, min: 0, max: 4 },
41
41
  base_note: { def: 16, min: 16, max:100 },
42
42
  semitones: { def:120, min: 36, max:120 },
43
- scroll: { def: 0, min: 0, max: 1 },
43
+ scroll: { def: 0, min: 0, max: 3 },
44
44
  left_color: { def:0xdcb900, min:0, max:0xffffff },
45
45
  mid_color: { def:0xdcdcdc, min:0, max:0xffffff },
46
46
  right_color:{ def:0x00b9dc, min:0, max:0xffffff },
@@ -91,56 +91,6 @@ import {ShowCQTElement} from "../../showcqt-element@3/showcqt-element.mjs";
91
91
  element.style.zIndex = z_index;
92
92
  }
93
93
 
94
- const icon_16 = get_asset("icon-16.png");
95
- const af_links = document.createElement("div");
96
- set_fixed_style(af_links, 10000001);
97
- af_links.style.padding = "8px";
98
- af_links.style.border = "thin solid white";
99
- af_links.style.backgroundColor = "#000000DD";
100
- af_links.style.color = "#dddddd";
101
- af_links.style.fontSize = "10pt";
102
- af_links.style.right = "8px";
103
- af_links.style.bottom = "calc(var(--ytms-cqt-bottom, 0px) + 8px)";
104
- af_links.style.opacity = 1;
105
- {
106
- const e = (name, ...args) => {
107
- const v = document.createElement(name);
108
- for (const arg of args)
109
- if (typeof arg == "object" && !(arg instanceof Node))
110
- v.setAttribute(...Object.entries(arg)[0])
111
- else
112
- v.append(arg);
113
- return v;
114
- };
115
- af_links.attachShadow({mode: "open"}).append(
116
- e("style",
117
- `:host { opacity: 0; max-width: 700px; }
118
- a, a:visited { color: #ffffff; font-weight: bold; }
119
- a:hover { color: #ffffa0; }
120
- :host(:hover) { opacity: 1; }
121
- img { vertical-align: middle; }`),
122
- e("div", {style: "text-align: right;"},
123
- e("img", {alt: "YTMS"}, {src: icon_16}, {style: "curson: pointer;"}),
124
- " Support me on ",
125
- e("a", {href: "https://www.youtube.com/@mfcc64"}, {target: "_blank"}, "YouTube"), " ",
126
- e("a", {href: "https://github.com/mfcc64"}, {target: "_blank"}, "GitHub"), " ",
127
- e("a", {href: "https://paypal.me/mfcc64"}, {target: "_blank"}, "PayPal"), " ",
128
- e("a", {href: "https://saweria.co/mfcc64"}, {target: "_blank"}, "Saweria")
129
- )
130
- );
131
- }
132
-
133
- let af_links_timeout = false;
134
- setTimeout(() => {
135
- af_links.style.opacity = "";
136
- af_links_timeout = true,
137
- update_af_links();
138
- }, 15000);
139
-
140
- function update_af_links() {
141
- af_links.style.display = !af_links_timeout || (child_menu.visible?.checked ?? true) ? "block" : "none";
142
- }
143
-
144
94
  const cqt = new ShowCQTElement();
145
95
  let svideos = [];
146
96
  if (document.location.hostname == "soundcloud.com") {
@@ -167,6 +117,7 @@ import {ShowCQTElement} from "../../showcqt-element@3/showcqt-element.mjs";
167
117
  set_fixed_style(cqt, 9999999);
168
118
  cqt.style.setProperty("user-select", "none");
169
119
  cqt.style.setProperty("-webkit-user-select", "none");
120
+ cqt.style.transformOrigin = "bottom left";
170
121
 
171
122
  let stop_count = 0;
172
123
  const videos = document.getElementsByTagName("video");
@@ -197,16 +148,13 @@ import {ShowCQTElement} from "../../showcqt-element@3/showcqt-element.mjs";
197
148
  #main-panel { align-items: flex-start !important; }
198
149
  #player { margin-top: 0 !important; }`;
199
150
  document.head.appendChild(style);
200
- af_links.style.zIndex = 11;
201
151
  cqt.style.zIndex = 10;
202
152
 
203
153
  function update_cqt_bottom() {
204
154
  if (document.fullscreenElement) {
205
155
  document.body.style.setProperty("--ytms-cqt-bottom", "0px");
206
- af_links.style.visibility = "hidden";
207
156
  } else {
208
157
  document.body.style.setProperty("--ytms-cqt-bottom", "var(--ytmusic-player-bar-height, 0px)");
209
- af_links.style.visibility = "visible";
210
158
  }
211
159
  }
212
160
 
@@ -216,7 +164,6 @@ import {ShowCQTElement} from "../../showcqt-element@3/showcqt-element.mjs";
216
164
 
217
165
  function spotify_layout() {
218
166
  cqt.style.zIndex = 4;
219
- af_links.style.zIndex = 5;
220
167
  document.body.style.setProperty("--ytms-cqt-bottom", "88px"); // FIXME
221
168
  const old_play = HTMLMediaElement.prototype.play;
222
169
  HTMLMediaElement.prototype.play = async function() {
@@ -237,7 +184,6 @@ import {ShowCQTElement} from "../../showcqt-element@3/showcqt-element.mjs";
237
184
 
238
185
  function soundcloud_layout() {
239
186
  cqt.style.zIndex = 1000;
240
- af_links.style.zIndex = 1001;
241
187
  document.body.style.setProperty("--ytms-cqt-bottom", "var(--play-controls-height, 0px)");
242
188
  }
243
189
 
@@ -260,6 +206,12 @@ import {ShowCQTElement} from "../../showcqt-element@3/showcqt-element.mjs";
260
206
  coord_line_h.style.pointerEvents = coord_line_v.style.pointerEvents = "none";
261
207
  coord_line_h.style.display = coord_line_v.style.display = "none";
262
208
 
209
+ function update_axis() {
210
+ if (!child_menu.axis || !child_menu.scroll)
211
+ return;
212
+ cqt.dataset.axis = axis_list[child_menu.axis.value][+(child_menu.scroll.value > 1)];
213
+ }
214
+
263
215
  function update_cqt_layout(child) {
264
216
  if (!child_menu.height || !child_menu.scroll || !child_menu.base_note || !child_menu.semitones)
265
217
  return;
@@ -276,24 +228,37 @@ import {ShowCQTElement} from "../../showcqt-element@3/showcqt-element.mjs";
276
228
  const vleft = -base / width;
277
229
  const vwidth = 120 / width;
278
230
 
279
- if (child_menu.scroll.value == "0") {
231
+ if (child_menu.scroll.value % 2 == 0) {
280
232
  cqt.style.height = `calc(${ child_menu.height.value / 100} * (100% - var(--ytms-cqt-bottom, 0px)))`;
281
233
  cqt.style.width = vwidth * 100 + "%";
282
234
  cqt.style.left = vleft * 100 + "%";
283
- cqt.style.bottom = "var(--ytms-cqt-bottom, 0px)";
284
- cqt.style.transform = "";
235
+
236
+ if (child_menu.scroll.value == 0) {
237
+ cqt.style.bottom = "var(--ytms-cqt-bottom, 0px)";
238
+ cqt.style.transform = "";
239
+ } else {
240
+ cqt.style.bottom = "100%";
241
+ cqt.style.transform = "scale(1, -1)";
242
+ }
285
243
  } else {
286
244
  cqt.style.height = child_menu.height.value + "vw";
287
245
  cqt.style.width = `calc(${vwidth} * (100vh - var(--ytms-cqt-bottom, 0px)))`;
288
- cqt.style.left = "100vw";
289
246
  cqt.style.bottom = `calc(var(--ytms-cqt-bottom, 0px) + ${vleft} * (100vh - var(--ytms-cqt-bottom, 0px)))`;
290
- cqt.style.transform = "rotate(-90deg)";
291
- cqt.style.transformOrigin = "bottom left";
247
+
248
+ if (child_menu.scroll.value == 1) {
249
+ cqt.style.left = "100vw";
250
+ cqt.style.transform = "rotate(-90deg)";
251
+ } else {
252
+ cqt.style.left = "0";
253
+ cqt.style.transform = "rotate(-90deg) scale(1, -1)";
254
+ }
292
255
  }
256
+
257
+ update_axis();
293
258
  }
294
259
 
295
260
  child_menu.axis = { value: get_opt("axis") };
296
- child_menu.axis.onchange = function() { cqt.dataset.axis = axis_list[child_menu.axis.value]; };
261
+ child_menu.axis.onchange = update_axis;
297
262
  cqt.shadowRoot.getElementById("axis").addEventListener("click", function() {
298
263
  child_menu.axis.value = (child_menu.axis.value + 1) % axis_list.length;
299
264
  child_menu.axis.onchange();
@@ -318,6 +283,8 @@ import {ShowCQTElement} from "../../showcqt-element@3/showcqt-element.mjs";
318
283
  var menu_div = document.createElement("div");
319
284
  var menu_table = document.createElement("div");
320
285
  set_fixed_style(menu_div, 10000001);
286
+ menu_div.lang = "en";
287
+ menu_div.dir = "ltr";
321
288
  menu_div.style.left = "0px";
322
289
  menu_div.style.top = "0px";
323
290
  menu_div.style.padding = "8px";
@@ -585,7 +552,7 @@ import {ShowCQTElement} from "../../showcqt-element@3/showcqt-element.mjs";
585
552
  child.onchange();
586
553
  }
587
554
 
588
- create_child_select_menu("Scroll", "scroll", [ "Vertical", "Horizontal" ], update_cqt_layout);
555
+ create_child_select_menu("Scroll", "scroll", [ "Vertical", "Horizontal", "Flip Vertical", "Flip Horizontal" ], update_cqt_layout);
589
556
 
590
557
  function detect_peak(color) {
591
558
  if (color_int[3] == 0xffffff)
@@ -790,7 +757,6 @@ import {ShowCQTElement} from "../../showcqt-element@3/showcqt-element.mjs";
790
757
  coord_line_h.style.display = coord_line_v.style.display = "none";
791
758
  cqt.render_clear();
792
759
  }
793
- update_af_links();
794
760
  });
795
761
 
796
762
  function create_child_select_presets() {
@@ -974,6 +940,5 @@ import {ShowCQTElement} from "../../showcqt-element@3/showcqt-element.mjs";
974
940
  document.body.appendChild(cqt);
975
941
  document.body.appendChild(coord_line_h);
976
942
  document.body.appendChild(coord_line_v);
977
- document.body.appendChild(af_links);
978
943
  dispatchEvent(new CustomEvent("youtube-musical-spectrum-is-available"));
979
944
  })().catch(e => console.error(e));