'use strict';

const albumSelector = '.player__album-text > a';
const trackSelector = '.player .player__title';
const albumLabelSelector = '.player__album-text';
const featArtistSelector = '.player .player__featuring';

Connector.artistSelector = '.player .player__artist';

Connector.getAlbum = () => {
	if (isAlbum()) {
		return Util.getTextFromSelectors(albumSelector);
	}

	return null;
};

Connector.getTrack = () => {
	const track = Util.getTextFromSelectors(trackSelector);
	const featArtist = Util.getTextFromSelectors(featArtistSelector);

	if (featArtist) {
		return `${track} (${featArtist})`;
	}

	return track;
};

Connector.playerSelector = '.player';

Connector.isPlaying = () => {
	return $('.play-button--playing').length > 0;
};

Connector.currentTimeSelector = '.waveform__elapsed';

Connector.durationSelector = '.waveform__duration';

/**
 * Check if an album is playing.
 * @return {Boolean} Check result
 */
function isAlbum() {
	const label = Util.getTextFromSelectors(albumLabelSelector);
	if (label) {
		return label.includes('Album');
	}

	return false;
}

@@ -1076,8 +1076,256 @@
 alse;%0A%7D%0A
+%0AConnector.getTrackArt = () =%3E %7B%0A%09const trackArt = $('.avatar-container img').attr('src');%0A%09if (!trackArt) %7B%0A%09%09return null;%0A%09%7D%0A%09const endIdx = trackArt.includes('?') ? trackArt.indexOf('?') : trackArt.length;%0A%09return trackArt.substr(0, endIdx);%0A%7D;%0A

Add audiomack track art support (#2133)