-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
35 lines (28 loc) · 1.04 KB
/
index.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
34
35
const { app, BrowserWindow, BrowserView } = require("electron");
const path = require('path');
function boot () {
let win = new BrowserWindow({ width: 1800, height: 1600 })
win.on('closed', () => {
win = null
})
let view = new BrowserView({
webPreferences: {
preload: path.join(__dirname, 'preload.js')
}
})
win.setBrowserView(view)
view.setBounds({ x: 0, y: 0, width: 1800, height:1600 })
// view.webContents.loadURL('https://www.bbc.com');
view.webContents.loadURL('https://reddit.com');
view.webContents.on("did-frame-finish-load", function (e, isMainFrame, frameProcessId, frameRoutingId) {
console.log(`frame finished loading. main/process/routing ${isMainFrame}, ${frameProcessId}, ${frameRoutingId}`)
view.webContents.send("from_mainland", {"command": "track_frame", "frameRoutingId": frameRoutingId, "isMainFrame": isMainFrame})
if (isMainFrame) {
setTimeout(_ => {
view.webContents.send("from_mainland", {"command": "trigger_access"});
}, 2000);
}
});
view.webContents.openDevTools();
}
app.on("ready", boot);