-
-
Notifications
You must be signed in to change notification settings - Fork 43
/
bearded-spice.js
49 lines (44 loc) · 1.65 KB
/
bearded-spice.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// Bearded spice strategy for the web interface of Euterpe.
// With this you can control your Euterpe via media controls under OSX.
// What is bearded spice you ask? https://github.com/beardedspice/beardedspice
// What about Euterpe? https://github.com/ironsmile/euterpe
BSStrategy = {
version: 1,
displayName: "Euterpe",
accepts: {
method: "predicateOnTab",
format: "%K LIKE[c] '*Euterpe'",
args: ["title"]
},
isPlaying: function () { return document.title.match(/.*\| Euterpe$/) !== null; },
toggle: function () {
var playing = (document.title.match(/.*\| Euterpe$/) !== null);
if (playing) {
document.querySelector('.jp-pause').click();
} else {
document.querySelector('.jp-play').click();
}
},
previous: function () { document.querySelector('.jp-previous').click(); },
next: function () { document.querySelector('.jp-next').click(); },
pause: function () { document.querySelector('.jp-pause').click(); },
favorite: function () { /* there is no favourite feature in this player */ },
trackInfo: function () {
var selected = document.querySelector('a.jp-playlist-current');
var artist = document.querySelector('a.jp-playlist-current > .jp-artist').innerText.slice(3);
var trackNumberedText = selected.innerText;
var album = document.querySelector('li.jp-playlist-current').children[0].children[1].children[0].innerText;
var m = trackNumberedText.match(/\d+\.\s+(.+) by/);
if (m) {
track = m[1];
} else {
track = trackNumberedText;
}
return {
'track': track,
'album': album,
'artist': artist,
'favorited': false
};
}
};