-
Notifications
You must be signed in to change notification settings - Fork 2
/
rtc-preload.js
28 lines (25 loc) · 993 Bytes
/
rtc-preload.js
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
const { contextBridge, ipcRenderer } = require('electron');
contextBridge.exposeInMainWorld('electronAPI', {
handleGetOBSWSdetails: () => ipcRenderer.invoke('get-obsWSdetails')
})
var scripts = [
{"source":"./obs-ws.js","type":"","async":false},
{"source":"./obsConnect.js","type":"","async":false},
{"source":"./rtc-renderer.js","type":"","async":false}
]
//Insert javascript
window.addEventListener('DOMContentLoaded', async () => {
scripts.forEach(script => {
const scriptElem = document.createElement('script');
scriptElem.src = script.source;
scriptElem.async = script.async;
if(script.type){scriptElem.type = script.type;}
scriptElem.onload = () => {
console.log(`${script.source} Script loaded successfuly`);
};
scriptElem.onerror = () => {
console.log(`${script.source} Error occurred while loading script`);
};
document.body.appendChild(scriptElem);
});
})