forked from beardedspice/BS-Strategies
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBBCSounds.bsstrategy
56 lines (55 loc) · 1.85 KB
/
BBCSounds.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
53
54
55
56
//
// BBCSounds.js
// BeardedSpice
//
// Created by Ben Pollman on 02/12/19.
// Copyright (c) 2019 Ben Pollman. All rights reserved.
//
BSStrategy = {
version:1,
displayName:"BBC Sounds",
accepts: {
method: "predicateOnTab",
format:"%K LIKE[c] '*.bbc.co.uk/sounds/play/*'",
args: ["URL"]
},
isPlaying:function () {
let iframe = window.parent.document.querySelector('#smphtml5iframesmp-wrapper');
return (iframe != null) && (iframe.contentDocument.querySelector('#p_audioui_playpause_playIcon').style.opacity == "0");
},
toggle:function () {
let iframe = window.parent.document.querySelector('#smphtml5iframesmp-wrapper');
if (iframe != null) {
iframe.contentDocument.querySelector('#p_audioui_playpause').click();
}
},
next: function () {
let iframe = window.parent.document.querySelector('#smphtml5iframesmp-wrapper');
if (iframe != null) {
iframe.contentDocument.querySelector('#p_audioui_nextButton').click();
}
},
favorite: function () {
},
previous: function () {
let iframe = window.parent.document.querySelector('#smphtml5iframesmp-wrapper');
if (iframe != null) {
iframe.contentDocument.querySelector('#p_audioui_previousButton').click();
}
},
pause: function () {
let iframe = window.parent.document.querySelector('#smphtml5iframesmp-wrapper');
if (iframe != null) {
iframe.contentDocument.querySelector('#p_audioui_playpause').click();
}
},
trackInfo: function () {
let art= window.parent.document.querySelector('.play-c-header-image img');
let title= window.parent.document.querySelector('h3');
let artist= window.parent.document.querySelector('h1');
return {'image': art ? art.src : null,
'track': title ? title.innerText : document.title,
'artist': artist ? artist.innerText : null
};
}
}