-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathNTSRadio.bsstrategy
51 lines (45 loc) · 1.28 KB
/
NTSRadio.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
//
// NTS Radio
// BeardedSpice
//
//
// Created by Grant Levene on 07/08/20
// Copyright (c) 2020 Tyler Rhodes / Jose Falcon. All rights reserved.
//
BSStrategy = {
version: 1,
displayName: "NTS Radio",
accepts: {
method: "predicateOnTab",
format: "%K LIKE[c] '*www.nts.live*'",
args: ["URL"]
},
pause: function() {
const mixcloudContent = document.getElementById("mixcloud-content");
if (mixcloudContent) {
const widget = window.Mixcloud.PlayerWidget(mixcloudContent);
widget.ready.then(function() {
widget.pause();
});
}
document.dispatchEvent(new CustomEvent("ntsStopRadio"));
},
toggle: function() {
const mixcloudContent = document.getElementById("mixcloud-content");
const radioPlayer = document.querySelector("audio");
if (mixcloudContent) {
const widget = window.Mixcloud.PlayerWidget(mixcloudContent);
widget.ready.then(function() {
widget.togglePlay();
});
return;
}
if (radioPlayer) {
if (radioPlayer.paused) {
radioPlayer.play();
} else {
radioPlayer.pause();
}
}
}
};