-
Notifications
You must be signed in to change notification settings - Fork 16
/
preload.js
33 lines (28 loc) · 957 Bytes
/
preload.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
const ipc = require('electron').ipcRenderer;
setInterval(function() {
// required since webviews can't access the renderer itself
ipc.send("title", document.title); // send update request to renderer
}, 500)
ipc.on('playback-control', (event, arg) => {
var doc = document;
switch (arg) {
case "Play":
var playBtn = doc.querySelector("#player button.js-play")
var pauseBtn = doc.querySelector("#player button.js-pause")
var playPauseContainer= doc.querySelector("#player .play-controls__main-button")
if (playPauseContainer.className.indexOf("playing") == -1)
playBtn.click()
else
pauseBtn.click()
break;
case "Next":
doc.querySelector("#player button.js-next").click();
break;
case "Previous":
doc.querySelector("#player button.js-previous").click();
break;
case "Stop":
doc.querySelector("#player button.js-pause").click();
break;
}
});