This repository has been archived on 2023-10-03. You can view files and clone it, but cannot push or open issues or pull requests.
NervUpdaterClient/preload.js
2023-02-06 16:44:17 +01:00

19 lines
730 B
JavaScript

// All the Node.js APIs are available in the preload process.
// It has the same sandbox as a Chrome extension.
const { contextBridge, ipcRenderer } = require('electron')
contextBridge.exposeInMainWorld('electronAPI', {
handleError: (callback) => ipcRenderer.on("error-message", callback),
updateProgress: (callback) => ipcRenderer.on('github-lookup', callback)
})
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])
}
})