mirror of
https://github.com/Mastermindzh/tidal-hifi.git
synced 2024-11-22 21:42:46 +01:00
Add switch case for Video/Song
This commit is contained in:
parent
cac5db123f
commit
7a30b125ec
@ -15,6 +15,7 @@ let currentPlayStatus = statuses.paused;
|
|||||||
let barvalue;
|
let barvalue;
|
||||||
let updatecurrent = false;
|
let updatecurrent = false;
|
||||||
let oldcurrent;
|
let oldcurrent;
|
||||||
|
let currentURL = undefined;
|
||||||
|
|
||||||
const elements = {
|
const elements = {
|
||||||
play: '*[data-test="play"]',
|
play: '*[data-test="play"]',
|
||||||
@ -22,7 +23,7 @@ const elements = {
|
|||||||
next: '*[data-test="next"]',
|
next: '*[data-test="next"]',
|
||||||
previous: 'button[data-test="previous"]',
|
previous: 'button[data-test="previous"]',
|
||||||
title: '*[data-test^="footer-track-title"]',
|
title: '*[data-test^="footer-track-title"]',
|
||||||
artists: '*[data-test^="grid-item-detail-text-title-artist"]',
|
artists: '*[class^="elemental__text elemental__text css-oxcos"]',
|
||||||
home: '*[data-test="menu--home"]',
|
home: '*[data-test="menu--home"]',
|
||||||
back: '[class^="backwardButton"]',
|
back: '[class^="backwardButton"]',
|
||||||
forward: '[class^="forwardButton"]',
|
forward: '[class^="forwardButton"]',
|
||||||
@ -249,7 +250,7 @@ function updateMediaInfo(options, notify) {
|
|||||||
*/
|
*/
|
||||||
setInterval(function () {
|
setInterval(function () {
|
||||||
const title = elements.getText("title");
|
const title = elements.getText("title");
|
||||||
const url = elements.get("url").href.replace(/[^0-9]/g, "");
|
//const id = elements.get("url").href.replace(/[^0-9]/g, "");
|
||||||
const artists = elements.getText("artists");
|
const artists = elements.getText("artists");
|
||||||
const current = elements.getText("current");
|
const current = elements.getText("current");
|
||||||
const duration = elements.getText("duration");
|
const duration = elements.getText("duration");
|
||||||
@ -260,7 +261,7 @@ setInterval(function () {
|
|||||||
title,
|
title,
|
||||||
message: artists,
|
message: artists,
|
||||||
status: currentStatus,
|
status: currentStatus,
|
||||||
url: `https://tidal.com/browse/track/${url}`,
|
url: currentURL,
|
||||||
current: current,
|
current: current,
|
||||||
duration: duration,
|
duration: duration,
|
||||||
};
|
};
|
||||||
@ -283,6 +284,17 @@ setInterval(function () {
|
|||||||
updatecurrent = true;
|
updatecurrent = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Video/Song check if it's a video return URL as undefined due to it not having an id.
|
||||||
|
switch(elements.get("url")) {
|
||||||
|
case null:
|
||||||
|
currentURL = undefined;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
const id = elements.get("url").href.replace(/[^0-9]/g, "");
|
||||||
|
currentURL = `https://tidal.com/browse/track/${id}`;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if(updatecurrent) {
|
if(updatecurrent) {
|
||||||
if(options.current == oldcurrent && currentStatus != "paused") return;
|
if(options.current == oldcurrent && currentStatus != "paused") return;
|
||||||
oldcurrent = options.current;
|
oldcurrent = options.current;
|
||||||
|
Loading…
Reference in New Issue
Block a user