'use strict';

const filter = new MetadataFilter({
	track: cleanupTrack,
	artist: cleanupArtist,
});

Connector.playerSelector = 'div.playerUI';

Connector.artistSelector = 'div.playerUI div.marqueeContent div';

Connector.trackSelector = 'div.playerUI div.marqueeContent div';

Connector.currentTimeSelector = 'div.scrubControlCurrentTime';

Connector.durationSelector = 'div.scrubControlDuration';
Connector.isPlaying = () => {
	return Util.hasElementClass('button.playButton', 'playButton--pause');
};

Connector.onReady = Connector.onStateChanged;

Connector.applyFilter(filter);

function cleanupTrack(track) {
	// Extract a track title from a `Track by Artist` string.
	return track.replace(/^(.*?)\s(by)\s(.*?)$/s, '$1');
}

function cleanupArtist(artist) {
	// Extract the artist from a `Track by Artist` string.
	return artist.replace(/^(.*?)\s(by)\s(.*?)$/s, '$3');
}

@@ -26,12 +26,8 @@
 er =
- new
  Met
@@ -37,16 +37,29 @@
 taFilter
+.createFilter
 (%7B%0A%09trac
@@ -717,25 +717,25 @@
 by)%5Cs(.*?)$/
-s
+i
 , '$1');%0A%7D%0A%0A
@@ -868,17 +868,17 @@
 s(.*?)$/
-s
+i
 , '$3');

Fix cbcmusic connector