-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathBBCRadio.bsstrategy
52 lines (52 loc) · 1.73 KB
/
BBCRadio.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
//
// BBCRadio.plist
// BeardedSpice
//
// Created by Max Borghino on 12/13/15.
// Copyright (c) 2015 Tyler Rhodes / Jose Falcon. All rights reserved.
//
// strategy/site notes
// - no previous and next available on site
BSStrategy = {
version:1,
displayName:"BBC Radio",
accepts: {
method: "predicateOnTab",
format:"%K LIKE[c] '*bbc.co.uk/radio/player/*'",
args: ["URL"]
},
isPlaying:function () {
var s=document.querySelector('#controls');
return (s && (s.classList.contains('stoppable') || s.classList.contains('pausable')));
},
toggle:function () {
var s = document.querySelector('#controls');
var play = document.querySelector('#btn-play');
var pause = document.querySelector('#btn-pause');
if (s && (s.classList.contains('stoppable') || s.classList.contains('pausable'))) {
pause.click();
} else {
play.click();
}
},
next: function () {},
favorite: function () {document.querySelector('#toggle-mystations').click();},
previous: function () {},
pause: function () {document.querySelector('#btn-pause').click();},
trackInfo: function () {
var playlister=document.querySelector('.playlister'), art, title, artist;
if (playlister) {
art=document.querySelector('.playlister img'),
title=playlister.querySelector('.track .title'),
artist=playlister.querySelector('.track .artist');
} else {
art=document.querySelector('#main-image-wrapper img'),
title=document.querySelector('#parent-title a'),
artist=document.querySelector('#title a');
}
return {'image': art ? art.getAttribute('src') : null,
'track': title ? title.innerText : document.title,
'artist': artist ? artist.innerText : null
};
}
}