@mfcc64/ytms 16.0.0 → 17.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 +64 -15
package/package.json
CHANGED
package/script.mjs
CHANGED
|
@@ -99,7 +99,7 @@ import {ShowCQTElement} from "../../showcqt-element@2/showcqt-element.mjs";
|
|
|
99
99
|
af_links.style.color = "#FFFFFF";
|
|
100
100
|
af_links.style.fontSize = "10pt";
|
|
101
101
|
af_links.style.right = "8px";
|
|
102
|
-
af_links.style.bottom = "8px";
|
|
102
|
+
af_links.style.bottom = "calc(var(--ytms-cqt-bottom, 0px) + 8px)";
|
|
103
103
|
af_links.style.opacity = 1;
|
|
104
104
|
{
|
|
105
105
|
const e = (name, ...args) => {
|
|
@@ -119,7 +119,7 @@ import {ShowCQTElement} from "../../showcqt-element@2/showcqt-element.mjs";
|
|
|
119
119
|
e("div", {id: "message"},
|
|
120
120
|
e("h3", "YouTube Musical Spectrum"),
|
|
121
121
|
e("ul",
|
|
122
|
-
e("li", "By default, the visualization is visible on YT Music
|
|
122
|
+
e("li", "By default, the visualization is visible on YT Music, Spotify, and SoundCloud but hidden on YouTube page."),
|
|
123
123
|
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."),
|
|
124
124
|
e("li", "Click the ", e("img", {alt: "YTMS"}, {src: icon_16}), " icon at the top left corner to open/close settings."),
|
|
125
125
|
e("li", "Press ", e("b", "Ctrl+Alt+H"), " to open/close settings and show/hide the ", e("img", {alt: "YTMS"}, {src: icon_16}), " icon."),
|
|
@@ -138,7 +138,6 @@ import {ShowCQTElement} from "../../showcqt-element@2/showcqt-element.mjs";
|
|
|
138
138
|
e("img", {alt: "YTMS"}, {src: icon_16}, {style: "curson: pointer;"}, {id: "open_message"}),
|
|
139
139
|
" Support me on ",
|
|
140
140
|
e("a", {href: "https://www.youtube.com/@mfcc64"}, {target: "_blank"}, "Youtube"), " ",
|
|
141
|
-
e("a", {href: "https://www.patreon.com/mfcc64"}, {target: "_blank"}, "Patreon"), " ",
|
|
142
141
|
e("a", {href: "https://github.com/mfcc64"}, {target: "_blank"}, "GitHub"), " ",
|
|
143
142
|
e("a", {href: "https://paypal.me/mfcc64"}, {target: "_blank"}, "PayPal"), " ",
|
|
144
143
|
e("a", {href: "https://saweria.co/mfcc64"}, {target: "_blank"}, "Saweria")
|
|
@@ -157,7 +156,7 @@ import {ShowCQTElement} from "../../showcqt-element@2/showcqt-element.mjs";
|
|
|
157
156
|
af_links.style.display = !af_links_timeout || (child_menu.visible?.checked ?? true) ? "block" : "none";
|
|
158
157
|
}
|
|
159
158
|
|
|
160
|
-
const message_version =
|
|
159
|
+
const message_version = 13;
|
|
161
160
|
af_links.shadowRoot.getElementById("message").style.display = get_opt("message_version") == message_version ? "none" : "block";
|
|
162
161
|
af_links.shadowRoot.getElementById("close_message").addEventListener("click", function() {
|
|
163
162
|
set_opt("message_version", message_version);
|
|
@@ -167,18 +166,36 @@ import {ShowCQTElement} from "../../showcqt-element@2/showcqt-element.mjs";
|
|
|
167
166
|
af_links.shadowRoot.getElementById("message").style.display = "block";
|
|
168
167
|
});
|
|
169
168
|
|
|
169
|
+
const media_symbol = Symbol("media_symbol");
|
|
170
|
+
let svideos = [];
|
|
171
|
+
if (document.location.hostname == "soundcloud.com") {
|
|
172
|
+
await new Promise((res, rej) => {
|
|
173
|
+
const old = AudioContext.prototype.createMediaElementSource;
|
|
174
|
+
AudioContext.prototype.createMediaElementSource = function(media) {
|
|
175
|
+
const retval = old.call(this, media);
|
|
176
|
+
ShowCQTElement.global_audio_context = this;
|
|
177
|
+
svideos.push(media);
|
|
178
|
+
media[media_symbol] = retval;
|
|
179
|
+
res();
|
|
180
|
+
return retval;
|
|
181
|
+
};
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
|
|
170
185
|
const cqt = new ShowCQTElement();
|
|
171
186
|
set_fixed_style(cqt, 9999999);
|
|
172
187
|
let stop_count = 0;
|
|
173
188
|
const videos = document.getElementsByTagName("video");
|
|
174
|
-
|
|
189
|
+
const require_refresh = ["open.spotify.com", "soundcloud.com"].indexOf(document.location.hostname) < 0;
|
|
175
190
|
cqt.render_callback = function() {
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
191
|
+
if (require_refresh) {
|
|
192
|
+
let need_refresh = (videos.length != svideos.length);
|
|
193
|
+
for (let k = 0; k < videos.length && !need_refresh; k++)
|
|
194
|
+
need_refresh = (videos[k] != svideos[k]);
|
|
195
|
+
if (need_refresh) {
|
|
196
|
+
this.dataset.inputs = "video";
|
|
197
|
+
svideos = Array.from(videos);
|
|
198
|
+
}
|
|
182
199
|
}
|
|
183
200
|
|
|
184
201
|
let state = 0;
|
|
@@ -197,7 +214,6 @@ import {ShowCQTElement} from "../../showcqt-element@2/showcqt-element.mjs";
|
|
|
197
214
|
#player { margin-top: 0 !important; }`;
|
|
198
215
|
document.head.appendChild(style);
|
|
199
216
|
af_links.style.zIndex = 11;
|
|
200
|
-
af_links.style.bottom = "calc(var(--ytmusic-player-bar-height, 0) + 8px)";
|
|
201
217
|
cqt.style.zIndex = 10;
|
|
202
218
|
|
|
203
219
|
function update_cqt_bottom() {
|
|
@@ -214,8 +230,39 @@ import {ShowCQTElement} from "../../showcqt-element@2/showcqt-element.mjs";
|
|
|
214
230
|
update_cqt_bottom();
|
|
215
231
|
}
|
|
216
232
|
|
|
217
|
-
|
|
218
|
-
|
|
233
|
+
function spotify_layout() {
|
|
234
|
+
cqt.style.zIndex = 4;
|
|
235
|
+
af_links.style.zIndex = 5;
|
|
236
|
+
document.body.style.setProperty("--ytms-cqt-bottom", "88px"); // FIXME
|
|
237
|
+
const old_play = HTMLMediaElement.prototype.play;
|
|
238
|
+
HTMLMediaElement.prototype.play = async function() {
|
|
239
|
+
const ret = old_play.call(this);
|
|
240
|
+
if (this.isConnected || this instanceof HTMLAudioElement)
|
|
241
|
+
return ret;
|
|
242
|
+
for (const video of svideos)
|
|
243
|
+
if (this == video)
|
|
244
|
+
return ret;
|
|
245
|
+
|
|
246
|
+
svideos.push(this);
|
|
247
|
+
const source = cqt.audio_context.createMediaElementSource(this);
|
|
248
|
+
source.connect(cqt.audio_input);
|
|
249
|
+
source.connect(cqt.audio_context.destination);
|
|
250
|
+
return ret;
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
function soundcloud_layout() {
|
|
255
|
+
cqt.style.zIndex = 1000;
|
|
256
|
+
af_links.style.zIndex = 1001;
|
|
257
|
+
svideos[0][media_symbol].connect(cqt.audio_input);
|
|
258
|
+
document.body.style.setProperty("--ytms-cqt-bottom", "var(--play-controls-height, 0px)");
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
switch (document.location.hostname) {
|
|
262
|
+
case "music.youtube.com": ytmusic_layout(); break;
|
|
263
|
+
case "open.spotify.com": spotify_layout(); break;
|
|
264
|
+
case "soundcloud.com": soundcloud_layout(); break;
|
|
265
|
+
}
|
|
219
266
|
|
|
220
267
|
const coord_line_h = document.createElement("div");
|
|
221
268
|
const coord_line_v = document.createElement("div");
|
|
@@ -304,6 +351,7 @@ import {ShowCQTElement} from "../../showcqt-element@2/showcqt-element.mjs";
|
|
|
304
351
|
menu_div.style.visibility = "hidden";
|
|
305
352
|
menu_div.style.cursor = "default";
|
|
306
353
|
menu_table.style.width = "860px";
|
|
354
|
+
menu_div.style.display = "block";
|
|
307
355
|
|
|
308
356
|
var current_tr = null;
|
|
309
357
|
var current_tr_count = 0;
|
|
@@ -907,7 +955,8 @@ import {ShowCQTElement} from "../../showcqt-element@2/showcqt-element.mjs";
|
|
|
907
955
|
setTimeout(function(){ child.value = "Reset Default Settings"; }, 300);
|
|
908
956
|
});
|
|
909
957
|
|
|
910
|
-
menu_div.
|
|
958
|
+
menu_div.attachShadow({mode: "open"});
|
|
959
|
+
menu_div.shadowRoot.appendChild(menu_table);
|
|
911
960
|
menu.onclick = function() {
|
|
912
961
|
menu_is_hidden = !menu_is_hidden;
|
|
913
962
|
if (menu_is_hidden)
|