From abe6671ed9494f132f5bba08df0917599afb22de Mon Sep 17 00:00:00 2001 From: Mehavoid <63477090+Mehavoid@users.noreply.github.com> Date: Wed, 8 Nov 2023 23:49:11 +0300 Subject: [PATCH] Fix connector for BrainFM (#4272) * Fix connector for BrainFM * Apply linter rules --- src/connectors/brainfm.ts | 15 ++++++++++++--- src/core/connectors.ts | 2 +- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/connectors/brainfm.ts b/src/connectors/brainfm.ts index a66159e0a8..ffee5bac05 100644 --- a/src/connectors/brainfm.ts +++ b/src/connectors/brainfm.ts @@ -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'; diff --git a/src/core/connectors.ts b/src/core/connectors.ts index f1fbbaf455..9884bf6b1c 100644 --- a/src/core/connectors.ts +++ b/src/core/connectors.ts @@ -1579,7 +1579,7 @@ export default [ }, { label: 'Brain.fm', - matches: ['*://www.brain.fm/*'], + matches: ['*://my.brain.fm/*'], js: 'brainfm.js', id: 'brainfm', },