removed garbage
This commit is contained in:
parent
4a440c9dd6
commit
0f081bbce5
32
main.js
32
main.js
@ -10,11 +10,7 @@ let mainWindow
|
||||
let logWindow
|
||||
|
||||
let devMode = false
|
||||
let selfMute = false
|
||||
let isConnected = false
|
||||
let webViewSession = null
|
||||
let configObj
|
||||
let micPermissionGranted = false
|
||||
|
||||
// Set Dev mode
|
||||
if (process.argv.length === 3) {
|
||||
@ -180,9 +176,8 @@ app.on('ready', () => {
|
||||
webViewSession.setPermissionRequestHandler((webContents, permission, callback) => { // deny all permissions
|
||||
const url = webContents.getURL()
|
||||
if (url.startsWith('https://discord.com/')) {
|
||||
if (permission === 'media' && isConnected === true) { // if user is connected to Discord voice then enable microphone
|
||||
console.log("User connected to Discord VOIP server. Granted permission for microphone")
|
||||
micPermissionGranted = true
|
||||
if (permission === 'media') { // if user is connected to Discord voice then enable microphone
|
||||
console.log("Granted permission for 'media'");
|
||||
return callback(true)
|
||||
}
|
||||
}
|
||||
@ -193,29 +188,6 @@ app.on('ready', () => {
|
||||
|
||||
ipcMain.on('asynchronous-message', (event, _data) => {
|
||||
let msg = _data.msg
|
||||
if (msg === 'connected') {
|
||||
console.log("User connected to Discord VOIP server")
|
||||
if (micPermissionGranted === false && selfMute === false){
|
||||
micPermissionGranted = true
|
||||
}
|
||||
isConnected = true
|
||||
}
|
||||
|
||||
if (msg === 'disconnected') {
|
||||
console.log("User disconnected to Discord VOIP server")
|
||||
isConnected = false
|
||||
}
|
||||
|
||||
if (msg === 'self-muted') {
|
||||
console.log("User self-muted")
|
||||
webViewSession.setPermissionRequestHandler(null)
|
||||
selfMute = true
|
||||
}
|
||||
|
||||
if (msg === 'self-unmuted') {
|
||||
console.log("User self-unmuted")
|
||||
selfMute = false
|
||||
}
|
||||
|
||||
if (msg === 'DOMready') {
|
||||
console.log("Discord webview loaded")
|
||||
|
@ -41,22 +41,6 @@ window.addEventListener(
|
||||
ipcRenderer.send('asynchronous-message', {msg: 'disconnected'})
|
||||
}
|
||||
|
||||
if (event.data.type === 'self-muted'){
|
||||
ipcRenderer.send('asynchronous-message', {msg:'self-muted'})
|
||||
}
|
||||
|
||||
if (event.data.type === 'self-unmuted'){
|
||||
ipcRenderer.send('asynchronous-message', {msg: 'self-unmuted'})
|
||||
}
|
||||
|
||||
if (event.data.type === 'confirmMicOpen'){
|
||||
ipcRenderer.send('asynchronous-message', {msg: 'confirmMicOpen'})
|
||||
}
|
||||
|
||||
if (event.data.type === 'confirmMicClose'){
|
||||
ipcRenderer.send('asynchronous-message', {msg: 'confirmMicClose'})
|
||||
}
|
||||
|
||||
if (event.data.type === 'blockUpdate'){
|
||||
ipcRenderer.send('asynchronous-message', {msg: 'blockUpdate', data: event.data.payload})
|
||||
}
|
||||
|
@ -49,7 +49,7 @@
|
||||
<webview
|
||||
id="discord"
|
||||
enableremotemodule="false"
|
||||
webpreferences="useragent='Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; AS; rv:11.0) like Gecko'"
|
||||
webpreferences="useragent='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.102 Safari/537.36"
|
||||
partition="persist:discord"
|
||||
src="https://discord.com/login"
|
||||
></webview>
|
||||
|
@ -152,29 +152,6 @@ onload = () => {
|
||||
|
||||
// Send commands to preload.js
|
||||
webview.addEventListener('console-message', (e) => {
|
||||
if (e.message.includes("RTC media connection state: CONNECTED")) {
|
||||
console.log("Connected to server")
|
||||
window.postMessage({ type: "connected"}, "*")
|
||||
removeBloat(webview)
|
||||
isConnectedToVoiceServer = true
|
||||
}
|
||||
|
||||
if (e.message.includes("RTC media connection state: DISCONNECTED")) {
|
||||
console.log("Disconnected from server")
|
||||
window.postMessage({ type: "disconnected"}, "*")
|
||||
isConnectedToVoiceServer = false
|
||||
}
|
||||
|
||||
if (e.message === "muted") {
|
||||
console.log("Self Muted in Discord")
|
||||
window.postMessage({ type: "self-muted"}, "*")
|
||||
}
|
||||
|
||||
if (e.message === "unmuted") {
|
||||
console.log("Self Un-Muted in Discord")
|
||||
window.postMessage({ type: "self-unmuted"}, "*")
|
||||
}
|
||||
|
||||
// Execute JS into the webview after login
|
||||
if (e.message === "--discord-load-complete") {
|
||||
userMuteDeafenListener(webview)
|
||||
|
Loading…
Reference in New Issue
Block a user