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