From 2c61c4be939f8a7a8a62e364ddb90f7041bc105e Mon Sep 17 00:00:00 2001 From: khlam <4841220+khlam@users.noreply.github.com> Date: Wed, 16 Oct 2019 13:52:33 -0700 Subject: [PATCH] remove download button --- index.html | 4 ++-- renderer.js | 30 ++++++++++++++++++++++++------ 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/index.html b/index.html index 21ef0b1..ee9234d 100644 --- a/index.html +++ b/index.html @@ -15,8 +15,8 @@ - - + + diff --git a/renderer.js b/renderer.js index 138698c..5928eb5 100644 --- a/renderer.js +++ b/renderer.js @@ -4,23 +4,41 @@ onload = () => { const webview = document.querySelector('webview') ipcRenderer.send('asynchronous-message', 'DOMready') + + // Execute JS into the webview to detect when logging in is complete + webview.addEventListener('did-finish-load', function() { + webview.executeJavaScript(` + let dlButton = document.getElementsByClassName("listItem-2P_4kh"); + t = setInterval(function(){ + if(dlButton.length != 0) { + console.log("discord-load-complete") + clearInterval(t) + }else { + console.log("waiting for load") + } + }, 1500); + `) + }); + webview.addEventListener('console-message', (e) => { if (e.message === "Constructed RTCPeerConnection") { console.log("Connected to server") ipcRenderer.send('asynchronous-message', 'connected') - // The only place where we execute arbitrary JS into the webview. This is to remove the download button at the bottom of the server list. - // Obviously malicious actors could take this source and create their own malicious discord client that steals auth tokens or something. - webview.executeJavaScript(` - let x = document.getElementsByClassName("listItem-2P_4kh"); - x[x.length-1].innerHTML = ""; - `) } if (e.message === "Close RTCPeerConnection") { console.log("Disconnected from server") ipcRenderer.send('asynchronous-message', 'disconnected') } + + // Execute JS into the webview after login to remove the download button at the bottom of the server list. + if (e.message === "discord-load-complete") { + webview.executeJavaScript(` + let a = document.getElementsByClassName("listItem-2P_4kh"); + a[a.length-1].innerHTML = ""; + `) + } }) ipcRenderer.on('ping', (event, msg) => {