-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathsimple.mjs
More file actions
34 lines (30 loc) · 1000 Bytes
/
Copy pathsimple.mjs
File metadata and controls
34 lines (30 loc) · 1000 Bytes
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
import { Application } from '../index.js';
const app = new Application();
const window = app.createBrowserWindow({
title: 'Simple Example',
width: 800,
height: 600,
});
const webview = window.createWebview({
html: `<!DOCTYPE html>
<html>
<head>
<title>Simple Example</title>
</head>
<body>
<h1>Hello, WebviewJS!</h1>
<p>This is a simple example of a webview window.</p>
<code>#FFFFFF/#000000</code>
</body>
</html>`,
});
setInterval(() => {
const bg = Math.floor(Math.random() * 0xffffff) + 1;
const complementary = 0xffffff - bg;
webview.evaluateScript(`
document.body.style.backgroundColor = '#${bg.toString(16).padStart(6, '0')}';
document.body.style.color = '#${complementary.toString(16).padStart(6, '0')}';
document.querySelector('code').textContent = \`\${document.body.style.backgroundColor}/\${document.body.style.color}\`;
`);
}, 1000).unref();
app.run();