-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
111 lines (82 loc) · 2.39 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<!DOCTYPE html>
<html>
<head>
<title>YTPC (You watch Tube on PC)</title>
<style type="text/css">
* { padding: 0; margin: 0; }
html, body, #foo {
height: 100%;
}
#foo {
width: 100%;
}
#download {
position: absolute;
bottom: 0px;
width: 100%;
}
</style>
</head>
<body>
<webview id="foo" src="https://www.youtube.com/"></webview>
<script>
const { remote } = require('electron')
const { Menu, MenuItem } = remote
const customTitlebar = require('custom-electron-titlebar');
let MyTitleBar = new customTitlebar.Titlebar({
backgroundColor: customTitlebar.Color.fromHex('#444'),
shadow: true
});
const isMac = process.platform === 'darwin'
const menu = new Menu();
menu.append(new MenuItem({
label: 'เมนูหลัก',
submenu: [
isMac ? { label: 'ปิด',role: 'close' } : { label: 'ออกจากโปรแกรม',role: 'quit' }
]
}));
MyTitleBar.updateMenu(menu);
MyTitleBar.updateTitle('YTPC');
onload = () => {
const webview = document.querySelector('webview')
const indicator = document.querySelector('.indicator')
const loadstart = (e) => {
updatedownload()
}
const loadstop = (e) => {
updatedownload()
}
webview.addEventListener('did-start-loading', loadstart)
webview.addEventListener('did-stop-loading', loadstop)
}
function updatedownload() {
if (foo.getURL().search("watch") >= 0) {
const menu = new Menu();
menu.append(new MenuItem({
label: 'เมนูหลัก',
submenu: [
{
label: 'ดาว์นโหลด วิดีโอนี้',
click: async () => {
const { shell } = require('electron')
await shell.openExternal('https://th.savefrom.net/#url=' + foo.getURL())
}
},
isMac ? { label: 'ปิด',role: 'close' } : { label: 'ออกจากโปรแกรม',role: 'quit' }
]
}));
MyTitleBar.updateMenu(menu);
} else {
const menu = new Menu();
menu.append(new MenuItem({
label: 'เมนูหลัก',
click: async () => {
window.close();
}
}));
MyTitleBar.updateMenu(menu);
}
}
</script>
</body>
</html>