discord-sandboxed/renderer.js
2019-10-14 14:14:02 -07:00

30 lines
1.1 KiB
JavaScript

const { ipcRenderer } = require('electron')
onload = () => {
const webview = document.querySelector('webview')
//webview.openDevTools()
webview.addEventListener('console-message', (e) => {
if (e.message === "Constructed RTCPeerConnection") {
console.log("Connected to server")
ipcRenderer.send('asynchronous-message', 'connected')
}
if (e.message === "Close RTCPeerConnection") {
console.log("Disconnected from server")
ipcRenderer.send('asynchronous-message', 'disconnected')
}
})
ipcRenderer.on('ping', (event, message) => {
if (message === 'mic-open'){
console.log("talking")
webview.sendInputEvent({keyCode: 'Backspace', type: 'keyDown'});
webview.sendInputEvent({keyCode: 'Backspace', type: 'char'});
}
if (message === 'mic-closed'){
console.log("not talking")
webview.sendInputEvent({keyCode: 'Backspace', type: 'keyUp'});
webview.sendInputEvent({keyCode: 'Backspace', type: 'char'});
}
})
}