@mfcc64/ytms 20.0.0 → 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.
- package/package.json +1 -1
- package/script.mjs +37 -69
package/package.json
CHANGED
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@
|
|
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:
|
|
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") {
|
|
@@ -165,6 +115,10 @@ import {ShowCQTElement} from "../../showcqt-element@3/showcqt-element.mjs";
|
|
|
165
115
|
}
|
|
166
116
|
|
|
167
117
|
set_fixed_style(cqt, 9999999);
|
|
118
|
+
cqt.style.setProperty("user-select", "none");
|
|
119
|
+
cqt.style.setProperty("-webkit-user-select", "none");
|
|
120
|
+
cqt.style.transformOrigin = "bottom left";
|
|
121
|
+
|
|
168
122
|
let stop_count = 0;
|
|
169
123
|
const videos = document.getElementsByTagName("video");
|
|
170
124
|
const require_refresh = ["open.spotify.com", "soundcloud.com"].indexOf(document.location.hostname) < 0;
|
|
@@ -194,16 +148,13 @@ import {ShowCQTElement} from "../../showcqt-element@3/showcqt-element.mjs";
|
|
|
194
148
|
#main-panel { align-items: flex-start !important; }
|
|
195
149
|
#player { margin-top: 0 !important; }`;
|
|
196
150
|
document.head.appendChild(style);
|
|
197
|
-
af_links.style.zIndex = 11;
|
|
198
151
|
cqt.style.zIndex = 10;
|
|
199
152
|
|
|
200
153
|
function update_cqt_bottom() {
|
|
201
154
|
if (document.fullscreenElement) {
|
|
202
155
|
document.body.style.setProperty("--ytms-cqt-bottom", "0px");
|
|
203
|
-
af_links.style.visibility = "hidden";
|
|
204
156
|
} else {
|
|
205
157
|
document.body.style.setProperty("--ytms-cqt-bottom", "var(--ytmusic-player-bar-height, 0px)");
|
|
206
|
-
af_links.style.visibility = "visible";
|
|
207
158
|
}
|
|
208
159
|
}
|
|
209
160
|
|
|
@@ -213,7 +164,6 @@ import {ShowCQTElement} from "../../showcqt-element@3/showcqt-element.mjs";
|
|
|
213
164
|
|
|
214
165
|
function spotify_layout() {
|
|
215
166
|
cqt.style.zIndex = 4;
|
|
216
|
-
af_links.style.zIndex = 5;
|
|
217
167
|
document.body.style.setProperty("--ytms-cqt-bottom", "88px"); // FIXME
|
|
218
168
|
const old_play = HTMLMediaElement.prototype.play;
|
|
219
169
|
HTMLMediaElement.prototype.play = async function() {
|
|
@@ -234,7 +184,6 @@ import {ShowCQTElement} from "../../showcqt-element@3/showcqt-element.mjs";
|
|
|
234
184
|
|
|
235
185
|
function soundcloud_layout() {
|
|
236
186
|
cqt.style.zIndex = 1000;
|
|
237
|
-
af_links.style.zIndex = 1001;
|
|
238
187
|
document.body.style.setProperty("--ytms-cqt-bottom", "var(--play-controls-height, 0px)");
|
|
239
188
|
}
|
|
240
189
|
|
|
@@ -257,6 +206,12 @@ import {ShowCQTElement} from "../../showcqt-element@3/showcqt-element.mjs";
|
|
|
257
206
|
coord_line_h.style.pointerEvents = coord_line_v.style.pointerEvents = "none";
|
|
258
207
|
coord_line_h.style.display = coord_line_v.style.display = "none";
|
|
259
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
|
+
|
|
260
215
|
function update_cqt_layout(child) {
|
|
261
216
|
if (!child_menu.height || !child_menu.scroll || !child_menu.base_note || !child_menu.semitones)
|
|
262
217
|
return;
|
|
@@ -273,24 +228,37 @@ import {ShowCQTElement} from "../../showcqt-element@3/showcqt-element.mjs";
|
|
|
273
228
|
const vleft = -base / width;
|
|
274
229
|
const vwidth = 120 / width;
|
|
275
230
|
|
|
276
|
-
if (child_menu.scroll.value ==
|
|
231
|
+
if (child_menu.scroll.value % 2 == 0) {
|
|
277
232
|
cqt.style.height = `calc(${ child_menu.height.value / 100} * (100% - var(--ytms-cqt-bottom, 0px)))`;
|
|
278
233
|
cqt.style.width = vwidth * 100 + "%";
|
|
279
234
|
cqt.style.left = vleft * 100 + "%";
|
|
280
|
-
|
|
281
|
-
|
|
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
|
+
}
|
|
282
243
|
} else {
|
|
283
244
|
cqt.style.height = child_menu.height.value + "vw";
|
|
284
245
|
cqt.style.width = `calc(${vwidth} * (100vh - var(--ytms-cqt-bottom, 0px)))`;
|
|
285
|
-
cqt.style.left = "100vw";
|
|
286
246
|
cqt.style.bottom = `calc(var(--ytms-cqt-bottom, 0px) + ${vleft} * (100vh - var(--ytms-cqt-bottom, 0px)))`;
|
|
287
|
-
|
|
288
|
-
|
|
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
|
+
}
|
|
289
255
|
}
|
|
256
|
+
|
|
257
|
+
update_axis();
|
|
290
258
|
}
|
|
291
259
|
|
|
292
260
|
child_menu.axis = { value: get_opt("axis") };
|
|
293
|
-
child_menu.axis.onchange =
|
|
261
|
+
child_menu.axis.onchange = update_axis;
|
|
294
262
|
cqt.shadowRoot.getElementById("axis").addEventListener("click", function() {
|
|
295
263
|
child_menu.axis.value = (child_menu.axis.value + 1) % axis_list.length;
|
|
296
264
|
child_menu.axis.onchange();
|
|
@@ -315,6 +283,8 @@ import {ShowCQTElement} from "../../showcqt-element@3/showcqt-element.mjs";
|
|
|
315
283
|
var menu_div = document.createElement("div");
|
|
316
284
|
var menu_table = document.createElement("div");
|
|
317
285
|
set_fixed_style(menu_div, 10000001);
|
|
286
|
+
menu_div.lang = "en";
|
|
287
|
+
menu_div.dir = "ltr";
|
|
318
288
|
menu_div.style.left = "0px";
|
|
319
289
|
menu_div.style.top = "0px";
|
|
320
290
|
menu_div.style.padding = "8px";
|
|
@@ -582,7 +552,7 @@ import {ShowCQTElement} from "../../showcqt-element@3/showcqt-element.mjs";
|
|
|
582
552
|
child.onchange();
|
|
583
553
|
}
|
|
584
554
|
|
|
585
|
-
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);
|
|
586
556
|
|
|
587
557
|
function detect_peak(color) {
|
|
588
558
|
if (color_int[3] == 0xffffff)
|
|
@@ -787,7 +757,6 @@ import {ShowCQTElement} from "../../showcqt-element@3/showcqt-element.mjs";
|
|
|
787
757
|
coord_line_h.style.display = coord_line_v.style.display = "none";
|
|
788
758
|
cqt.render_clear();
|
|
789
759
|
}
|
|
790
|
-
update_af_links();
|
|
791
760
|
});
|
|
792
761
|
|
|
793
762
|
function create_child_select_presets() {
|
|
@@ -971,6 +940,5 @@ import {ShowCQTElement} from "../../showcqt-element@3/showcqt-element.mjs";
|
|
|
971
940
|
document.body.appendChild(cqt);
|
|
972
941
|
document.body.appendChild(coord_line_h);
|
|
973
942
|
document.body.appendChild(coord_line_v);
|
|
974
|
-
document.body.appendChild(af_links);
|
|
975
943
|
dispatchEvent(new CustomEvent("youtube-musical-spectrum-is-available"));
|
|
976
944
|
})().catch(e => console.error(e));
|