Skip to content
This repository has been archived by the owner on Dec 7, 2020. It is now read-only.

Add jazzradio connector #20

Merged
merged 6 commits into from May 22, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -27,6 +27,7 @@ other desktop widgets or provide keyboard-only control themselves.
- [listen.moe](https://listen.moe/)
- [YouTube](https://youtube.com)
- [Invidious](https://invidio.us)
- [JAZZRADIO](https://jazzradio.com)
doronbehar marked this conversation as resolved.
Show resolved Hide resolved
- [Google Play Music](https://play.google.com/music)
- [Spotify](https://www.spotify.com/)
- [Yandex.Music](https://music.yandex.ru)
Expand Down
43 changes: 43 additions & 0 deletions connectors/jazzradio.js
@@ -0,0 +1,43 @@
'use strict';

import BaseConnector from 'content/base-connector';
import Utils from 'content/utils';
import _ from 'underscore';

new class extends BaseConnector {
constructor() {
super();
this.name = 'JazzRadio';
this.prefix = '/com/jazzradio';
this.artistSelector = '.artist-name';
this.titleSelector = '.track-name';
this.lengthSelector = '.total';
this.currentTimeSelector = '.time';
this.artSelector = '#art';

Utils.query('#row-player-controls').then(elem => this.observe(elem));
}

get playbackStatus() {
return Utils.query('#play-button a').then(icon => {
if (icon.classList.contains('icon-pause')) {
return 'playing';
} else {
return 'paused';
}
});
}
playPause() {
this.playbackStatus.then((status) => {
if (status === 'playing') {
Utils.queryClick('.icon-pause');
} else {
Utils.queryClick('.icon-play');
}
});
}
get artist() {
return Utils.query(this.artistSelector)
.then(node => node.textContent.trim().replace(/ - $/, ''));
}
};
3 changes: 3 additions & 0 deletions manifest.json
Expand Up @@ -45,6 +45,9 @@
}, {
"matches": ["*://*.invidio.us/*"],
"js": [ "connectors/invidious.js" ]
}, {
"matches": ["*://*.jazzradio.com/*"],
"js": [ "connectors/jazzradio.js" ]
}, {
"matches": ["*://music.yandex.ru/*", "*://radio.yandex.ru/*"],
"js": [ "connectors/yandex-music.js" ]
Expand Down