2023-03-02 21:42:38 +00:00
|
|
|
/**
|
|
|
|
* The preload script runs before. It has access to web APIs
|
|
|
|
* as well as Electron's renderer process modules and some
|
|
|
|
* polyfilled Node.js functions.
|
|
|
|
*
|
|
|
|
* https://www.electronjs.org/docs/latest/tutorial/sandbox
|
|
|
|
*/
|
2024-08-14 15:03:19 +00:00
|
|
|
|
|
|
|
const { contextBridge, ipcRenderer } = require('electron');
|
|
|
|
|
|
|
|
contextBridge.exposeInMainWorld('electron', {
|
|
|
|
enforceDomainRestrictions: (url) => ipcRenderer.sendSync('check-domain', url),
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2023-03-02 21:42:38 +00:00
|
|
|
window.addEventListener('DOMContentLoaded', () => {
|
|
|
|
const replaceText = (selector, text) => {
|
|
|
|
const element = document.getElementById(selector)
|
|
|
|
if (element) element.innerText = text
|
|
|
|
}
|
|
|
|
|
|
|
|
for (const type of ['chrome', 'node', 'electron']) {
|
2024-08-12 23:38:02 +00:00
|
|
|
replaceText(`${type}-version`, 'sneedium-version')
|
2023-03-02 21:42:38 +00:00
|
|
|
}
|
2024-08-14 15:03:19 +00:00
|
|
|
|
2023-03-09 11:25:24 +00:00
|
|
|
ipcRenderer.on('windowmaker', (event, arg) => {
|
|
|
|
console.log(arg) // prints "pong"
|
|
|
|
})
|
|
|
|
//button and its event listener
|
|
|
|
const makeWindowButton = document.getElementById('nwBtn');
|
|
|
|
makeWindowButton.addEventListener('click', () => {
|
|
|
|
ipcRenderer.send('windowmaker', 'ping')
|
|
|
|
})
|
2023-03-02 21:42:38 +00:00
|
|
|
})
|