-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathindex.html
51 lines (51 loc) · 2.47 KB
/
index.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Undercast</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div style="height: 100%; width: 100%;">
<!-- webview serves as a Electron-safe version of iframe. preload.js contains helper functions that are injected into Overcast.fm session. -->
<webview id="overcast" src="https://overcast.fm/login" preload="preload.js" webpreferences="allowDisplayingInsecureContent=yes"></webview>
</div>
<script>
// The Remote package allows for safe communication between the main thread and the render thread.
const remote = require('electron').remote;
// Debugging dev tools for <webview> instance.
/*document.getElementById('overcast').addEventListener('dom-ready', () => {
document.getElementById('overcast').openDevTools()
})*/
// When a new page loads, the app automatically scrolls to the top of the media player or list.
document.getElementById('overcast').addEventListener('did-finish-load', () => {
if(document.getElementById('overcast').getURL() === 'https://overcast.fm/podcasts') {
document.getElementById('overcast').executeJavaScript('__myAPI.scrollList();');
}
else if(document.getElementById('overcast').getURL().slice(0,21) === 'https://overcast.fm/+') {
document.getElementById('overcast').executeJavaScript('__myAPI.scrollPlayer();');
}
})
// Remote commands to change menubar icon color.
document.getElementById('overcast').addEventListener('media-started-playing', () => {
remote.getGlobal('playing')();
})
document.getElementById('overcast').addEventListener('media-paused', () => {
remote.getGlobal('paused')();
})
// Media key functions. Triggered by functions in the main thread. Use preload.js APIs.
var playpause = function() {
document.getElementById('overcast').executeJavaScript('__myAPI.playpause();');
}
var stop = function() {
document.getElementById('overcast').executeJavaScript('__myAPI.stop();');
}
var next = function() {
document.getElementById('overcast').executeJavaScript('__myAPI.next();');
}
var previous = function() {
document.getElementById('overcast').executeJavaScript('__myAPI.previous();');
}
</script>
</body>
</html>