Skip to content
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
nnewc
/
node-usb-example-electron
Public
forked from
node-usb/node-usb-example-electron
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Files
Expand file tree
main
Breadcrumbs
node-usb-example-electron
/
preload.js
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
16 lines (13 loc) · 595 Bytes
main
Breadcrumbs
node-usb-example-electron
/
preload.js
Copy path
Top
File metadata and controls
Code
Blame
16 lines (13 loc) · 595 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
const { ipcRenderer } = require('electron')
// All of the Node.js APIs are available in the preload process.
// It has the same sandbox as a Chrome extension.
window.addEventListener('DOMContentLoaded', () => {
const replaceText = (selector, text) => {
const element = document.getElementById(selector)
if (element) element.innerText = text
}
for (const dependency of ['chrome', 'node', 'electron']) {
replaceText(`${dependency}-version`, process.versions[dependency])
}
ipcRenderer.on('devices', (_event, text) => replaceText('devices', text))
})
You can’t perform that action at this time.