forked from beardedspice/BS-Strategies
-
Notifications
You must be signed in to change notification settings - Fork 0
/
BE-AT.TV.bsstrategy
52 lines (49 loc) · 1.4 KB
/
BE-AT.TV.bsstrategy
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
50
51
52
//
// BE-AT.TV.js
// BeardedSpice
//
// Created by Marvin Tam on 10/25/2016.
// Copyright (c) 2016 GPL v3 http://www.gnu.org/licenses/gpl.html
//
BSStrategy = {
version: 1,
displayName: "BE-AT.TV",
accepts: {
method: "predicateOnTab",
format: "%K LIKE[c] '*be-at.tv*'",
args: ["URL"]
},
isPlaying: function() {
return document.querySelector('#radio .playbutton')
.style.display === 'none';
},
toggle: function() {
var playButton = document.querySelector('#radio .playbutton');
var pauseButton = document.querySelector('#radio .pausebutton');
playButton.style.display === 'none' ? pauseButton.click() :
playButton.click();
},
next: function() {
document.querySelector('#radio .next').click();
},
favorite: function() {}, // not applicable here
previous: function() {
document.querySelector('#radio .back').click();
},
pause: function() {
document.querySelector('#radio .pausebutton').click();
},
trackInfo: function() {
// Ticker format: "artist : track"
var items = document.querySelector('#radio .ticker').textContent
.split(':', 2);
// Get the un-resized thumbnail by removing the ?w=36&h36 query
var imageUrl = document.querySelector('#radio img').src;
imageUrl = imageUrl.slice(0, imageUrl.indexOf('?'));
return {
artist: items[0].trim(),
track: items[1].trim(),
image: imageUrl
};
}
}