discord-sandboxed/renderer.js

35 lines
1.2 KiB
JavaScript
Raw Normal View History

2019-10-14 18:31:48 +00:00
const unMuteSound = new Audio('./assets/unmute.mp3')
const muteSound = new Audio('./assets/mute.mp3')
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')
webview.openDevTools()
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'){
console.log("mic is open")
webview.sendInputEvent({keyCode: 'Backspace', type: 'keyDown'});
webview.sendInputEvent({keyCode: 'Backspace', type: 'char'});
//unMuteSound.play()
}
if (message === 'mic-closed'){
console.log("mic is closed")
webview.sendInputEvent({keyCode: 'Backspace', type: 'keyUp'});
webview.sendInputEvent({keyCode: 'Backspace', type: 'char'});
//muteSound.play()
}
})
}