Skip to content

Instantly share code, notes, and snippets.

@Jarrio
Created January 19, 2023 16:28
Show Gist options
  • Save Jarrio/e6da74e7ef46c58bf9ca7c219ee2b415 to your computer and use it in GitHub Desktop.
Save Jarrio/e6da74e7ef46c58bf9ca7c219ee2b415 to your computer and use it in GitHub Desktop.
electron preload.js
// preload.js
// All 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])
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment