This repository was archived by the owner on Jul 30, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbrowser.js
More file actions
47 lines (40 loc) · 1.45 KB
/
browser.js
File metadata and controls
47 lines (40 loc) · 1.45 KB
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
onload = () => {
const {ipcRenderer} = require('electron')
var wv = document.querySelector('webview');
document.getElementById('back').onclick = () => wv.goBack();
document.getElementById('fwd').onclick = () => wv.goForward();
document.getElementById('stop').onclick = () => wv.stop();
document.getElementById('refresh').onclick = () => wv.reload();
crash = () => {
ipcRenderer.send('open-dead');
}
oops = () => {
ipcRenderer.send('open-oops');
}
document.querySelector('#menu-bar').onclick = crash;
var breakage = document.querySelectorAll('.broken');
breakage.forEach(broke => {
broke.onclick = oops;
});
didStartLoad = (e) => {
console.log(e);
document.querySelector('#address').value = e.target.src;
}
didEndLoad = (e) => {
document.querySelector('#address').value = e.target.src;
}
didGetRedirect = (e) => {
console.log(e);
document.querySelector('#address').value = e.target.src;
}
wv.addEventListener('did-start-loading', didStartLoad);
wv.addEventListener('did-stop-loading', didEndLoad);
wv.addEventListener('did-get-redirect-request', didGetRedirect);
document.querySelector('#address').onkeydown = (e) => {
if (e.key == 'Enter') {
let url = document.querySelector('#address').value
if (url.indexOf('://') == -1) url = 'http://' + url;
wv.src = url;
}
}
}