Skip to content

Commit

Permalink
Fix connector for BrainFM (web-scrobbler#4272)
Browse files Browse the repository at this point in the history
* Fix connector for BrainFM

* Apply linter rules
  • Loading branch information
Mehavoid authored Nov 8, 2023
1 parent d419cd0 commit abe6671
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
15 changes: 12 additions & 3 deletions src/connectors/brainfm.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
export {};

Connector.playerSelector = '[class^="Controls__wrapper___"]';
Connector.playerSelector = '#root';

Connector.trackSelector = `${Connector.playerSelector} [class^="Controls__brainState___"]`;
Connector.pauseButtonSelector = '[data-testid="playPauseButton"] > div > img';

Connector.pauseButtonSelector = `${Connector.playerSelector} svg[class^=PlayControl__pause___]`;
Connector.trackArtSelector =
'[data-testid="currentTrackInformationCard"] > img';

Connector.getTrack = () => {
const elements = Util.queryElements('[data-testid="currentTrackTitle"]');
if (!elements) {
return null;
}
return elements[0]?.firstChild?.textContent;
};

Connector.getArtist = () => 'Brain.fm';
2 changes: 1 addition & 1 deletion src/core/connectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1579,7 +1579,7 @@ export default <ConnectorMeta[]>[
},
{
label: 'Brain.fm',
matches: ['*://www.brain.fm/*'],
matches: ['*://my.brain.fm/*'],
js: 'brainfm.js',
id: 'brainfm',
},
Expand Down

0 comments on commit abe6671

Please sign in to comment.