cleanup
This commit is contained in:
parent
588e7f6f99
commit
c46fd58fbc
24
main.js
24
main.js
@ -69,38 +69,25 @@ app.on('activate', function () {
|
||||
// code. You can also put them in separate files and require them here.
|
||||
|
||||
'use strict';
|
||||
|
||||
let isTalking = false
|
||||
let selfMute = false
|
||||
let isConnected = false
|
||||
|
||||
function muteMic() {
|
||||
if (isConnected === true) {
|
||||
return new Promise((resolve) => {
|
||||
if (isTalking === false) {
|
||||
console.log("Muted")
|
||||
mainWindow.webContents.send('micClose', 'mic-closed')
|
||||
mainWindow.setTitle("MUTED")
|
||||
return resolve(true)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
function unmuteMic() {
|
||||
if (isConnected === true) {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (isConnected === true && selfMute === false) {
|
||||
console.log("Talking")
|
||||
isTalking = true
|
||||
mainWindow.webContents.send('micOpen', 'mic-open')
|
||||
mainWindow.setTitle("MIC OPEN")
|
||||
return resolve(true)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
app.on('ready', event => {
|
||||
ioHook.start();
|
||||
|
||||
console.log(`Dev Mode: ${devMode}`)
|
||||
})
|
||||
|
||||
@ -112,7 +99,6 @@ ioHook.on('mousedown', event => {
|
||||
|
||||
ioHook.on('mouseup', event => {
|
||||
if (event.button == '4') {
|
||||
isTalking = false
|
||||
muteMic()
|
||||
}
|
||||
})
|
||||
@ -120,23 +106,21 @@ ioHook.on('mouseup', event => {
|
||||
ipcMain.on('asynchronous-message', (event, msg) => {
|
||||
if (msg === 'connected') {
|
||||
isConnected = true
|
||||
isTalking = false
|
||||
muteMic()
|
||||
}
|
||||
|
||||
if (msg === 'disconnected') {
|
||||
isConnected = false
|
||||
isTalking = false
|
||||
}
|
||||
|
||||
if (msg === 'self-muted') {
|
||||
console.log("self-muted")
|
||||
isConnected = false
|
||||
selfMute = true
|
||||
}
|
||||
|
||||
if (msg === 'self-unmuted') {
|
||||
console.log("self-unmuted")
|
||||
isConnected = true
|
||||
selfMute = false
|
||||
}
|
||||
|
||||
if (msg === 'DOMready') {
|
||||
|
16
renderer.js
16
renderer.js
@ -1,10 +1,8 @@
|
||||
const { remote, ipcRenderer } = require('electron')
|
||||
|
||||
function removeBloat(webview) {
|
||||
webview.executeJavaScript(`
|
||||
document.getElementsByClassName("anchor-3Z-8Bb anchorUnderlineOnHover-2ESHQB")[0].remove();
|
||||
document.getElementsByClassName("contents-18-Yxp button-3AYNKb button-2vd_v_")[0].remove();
|
||||
`)
|
||||
webview.executeJavaScript(`document.getElementsByClassName("anchor-3Z-8Bb anchorUnderlineOnHover-2ESHQB")[0].remove();`) // Remove top-right help button
|
||||
webview.executeJavaScript(`document.getElementsByClassName("contents-18-Yxp button-3AYNKb button-2vd_v_")[0].remove();`) // Remove gift from chat
|
||||
}
|
||||
|
||||
function muteMic(webview){
|
||||
@ -71,31 +69,27 @@ onload = () => {
|
||||
`)
|
||||
}
|
||||
|
||||
// To be finished
|
||||
if (e.message === "DOM changed") {
|
||||
removeBloat(webview)
|
||||
}
|
||||
|
||||
// Execute JS into the webview after login
|
||||
// Removes download button and help button
|
||||
if (e.message === "discord-load-complete") {
|
||||
webview.executeJavaScript(`
|
||||
document.getElementsByClassName("listItem-2P_4kh")[document.getElementsByClassName("listItem-2P_4kh").length - 1].remove();
|
||||
|
||||
`)
|
||||
webview.executeJavaScript(`document.getElementsByClassName("listItem-2P_4kh")[document.getElementsByClassName("listItem-2P_4kh").length - 1].remove();`) // Remove download button
|
||||
removeBloat(webview)
|
||||
}
|
||||
})
|
||||
|
||||
ipcRenderer.on('micOpen', (event, msg) => {
|
||||
if (msg === 'mic-open'){
|
||||
clearTimeout(muteTimeout)
|
||||
clearTimeout(muteTimeout) // Cancel mic-off incase of accidental double-tap
|
||||
console.log("talking")
|
||||
webview.sendInputEvent({keyCode: 'Backspace', type: 'keyDown'});
|
||||
webview.sendInputEvent({keyCode: 'Backspace', type: 'char'});
|
||||
document.getElementById("title-bar-status").style.backgroundColor = "green"
|
||||
document.getElementById("title-bar-controls").style.backgroundColor = "green"
|
||||
document.getElementById("title-bar").style.backgroundColor = "green"
|
||||
|
||||
}
|
||||
})
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user