discord-sandboxed/renderer.js

30 lines
1.1 KiB
JavaScript
Raw Normal View History

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