From f9c0ac39db4e3e8af4aa5e932478c01645f5caf0 Mon Sep 17 00:00:00 2001 From: khlam <4841220+khlam@users.noreply.github.com> Date: Thu, 25 Mar 2021 17:15:28 -0700 Subject: [PATCH] 1.0.1; Fix some change in client HTML that broke load detection. Fix user connected to voice channels addressing #14. --- package-lock.json | 37 +++++++++++++++++-------------------- package.json | 4 ++-- views/js/mainRender.js | 31 ++++--------------------------- 3 files changed, 23 insertions(+), 49 deletions(-) diff --git a/package-lock.json b/package-lock.json index 24bb341..efae0ac 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "discordsandbox", - "version": "1.0.0", + "version": "1.0.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "discordsandbox", - "version": "1.0.0", + "version": "1.0.1", "hasInstallScript": true, "license": "GNU GENERAL PUBLIC LICENSE Version 3", "dependencies": { @@ -15,7 +15,7 @@ "iohook": "^0.7.2" }, "devDependencies": { - "electron": "^7.2.4", + "electron": "^12.0.2", "electron-builder": "^21.2.0" } }, @@ -41,8 +41,6 @@ "debug": "^4.1.1", "env-paths": "^2.2.0", "fs-extra": "^8.1.0", - "global-agent": "^2.0.2", - "global-tunnel-ng": "^2.7.1", "got": "^9.6.0", "progress": "^2.0.3", "sanitize-filename": "^1.6.2", @@ -84,9 +82,9 @@ "dev": true }, "node_modules/@types/node": { - "version": "12.12.48", - "resolved": "https://registry.npmjs.org/@types/node/-/node-12.12.48.tgz", - "integrity": "sha512-m3Nmo/YaDUfYzdCQlxjF5pIy7TNyDTAJhIa//xtHcF0dlgYIBKULKnmloCPtByDxtZXrWV8Pge1AKT6/lRvVWg==", + "version": "14.14.36", + "resolved": "https://registry.npmjs.org/@types/node/-/node-14.14.36.tgz", + "integrity": "sha512-kjivUwDJfIjngzbhooRnOLhGYz6oRFi+L+EpMjxroDYXwDw9lHrJJ43E+dJ6KAd3V3WxWAJ/qZE9XKYHhjPOFQ==", "dev": true }, "node_modules/7zip-bin": { @@ -714,7 +712,6 @@ "dependencies": { "anymatch": "~3.1.1", "braces": "~3.0.2", - "fsevents": "~2.1.2", "glob-parent": "~5.1.0", "is-binary-path": "~2.1.0", "is-glob": "~4.0.1", @@ -1154,14 +1151,14 @@ } }, "node_modules/electron": { - "version": "7.2.4", - "resolved": "https://registry.npmjs.org/electron/-/electron-7.2.4.tgz", - "integrity": "sha512-Z+R692uTzXgP8AHrabE+kkrMlQJ6pnAYoINenwj9QSqaD2YbO8IuXU9DMCcUY0+VpA91ee09wFZJNUKYPMnCKg==", + "version": "12.0.2", + "resolved": "https://registry.npmjs.org/electron/-/electron-12.0.2.tgz", + "integrity": "sha512-14luh9mGzfL4e0sncyy0+kW37IU7Y0Y1tvI97FDRSW0ZBQxi5cmAwSs5dmPmNBFBIGtzkaGaEB01j9RjZuCmow==", "dev": true, "hasInstallScript": true, "dependencies": { "@electron/get": "^1.0.1", - "@types/node": "^12.0.12", + "@types/node": "^14.6.2", "extract-zip": "^1.0.3" }, "bin": { @@ -3836,9 +3833,9 @@ "dev": true }, "@types/node": { - "version": "12.12.48", - "resolved": "https://registry.npmjs.org/@types/node/-/node-12.12.48.tgz", - "integrity": "sha512-m3Nmo/YaDUfYzdCQlxjF5pIy7TNyDTAJhIa//xtHcF0dlgYIBKULKnmloCPtByDxtZXrWV8Pge1AKT6/lRvVWg==", + "version": "14.14.36", + "resolved": "https://registry.npmjs.org/@types/node/-/node-14.14.36.tgz", + "integrity": "sha512-kjivUwDJfIjngzbhooRnOLhGYz6oRFi+L+EpMjxroDYXwDw9lHrJJ43E+dJ6KAd3V3WxWAJ/qZE9XKYHhjPOFQ==", "dev": true }, "7zip-bin": { @@ -4766,13 +4763,13 @@ "dev": true }, "electron": { - "version": "7.2.4", - "resolved": "https://registry.npmjs.org/electron/-/electron-7.2.4.tgz", - "integrity": "sha512-Z+R692uTzXgP8AHrabE+kkrMlQJ6pnAYoINenwj9QSqaD2YbO8IuXU9DMCcUY0+VpA91ee09wFZJNUKYPMnCKg==", + "version": "12.0.2", + "resolved": "https://registry.npmjs.org/electron/-/electron-12.0.2.tgz", + "integrity": "sha512-14luh9mGzfL4e0sncyy0+kW37IU7Y0Y1tvI97FDRSW0ZBQxi5cmAwSs5dmPmNBFBIGtzkaGaEB01j9RjZuCmow==", "dev": true, "requires": { "@electron/get": "^1.0.1", - "@types/node": "^12.0.12", + "@types/node": "^14.6.2", "extract-zip": "^1.0.3" } }, diff --git a/package.json b/package.json index b7559a1..3e482bd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "discordsandbox", - "version": "1.0.0", + "version": "1.0.1", "description": "Discord Sandboxed", "main": "main.js", "scripts": { @@ -18,7 +18,7 @@ "author": "Kin-Ho Lam", "license": "GNU GENERAL PUBLIC LICENSE Version 3", "devDependencies": { - "electron": "^7.2.4", + "electron": "^12.0.2", "electron-builder": "^21.2.0" }, "dependencies": { diff --git a/views/js/mainRender.js b/views/js/mainRender.js index 598948d..3d3007c 100644 --- a/views/js/mainRender.js +++ b/views/js/mainRender.js @@ -40,6 +40,7 @@ function removeBloat(webview) { 'noticeBrand', 'actionButtons-14eAc_', ] + webview.executeJavaScript(`document.querySelectorAll('[aria-label="Download Apps"]')[document.querySelectorAll('[aria-label="Download Apps"]').length - 1].style.display = 'none';`) // Remove download button bloatList.forEach(function(tag){ webview.executeJavaScript(` document.querySelectorAll("div[class^=${tag}]").forEach(e => { @@ -50,27 +51,6 @@ function removeBloat(webview) { }) } -// Creates an observer for user list to detect if server is switched -function userListChangeListener(webview) { - webview.executeJavaScript(` - const userList = document.getElementsByClassName("sidebar-2K8pFh")[0] - const userListconfig = { attributes: false, childList: true, subtree: true, characterData: false }; - - const userListChangeCallback = function(mutationsList, observer) { - console.log('--user list changed'); - - if (document.querySelectorAll('[aria-label="Disconnect"]').length === 1){ - console.log('--user is connected to voice server') - }else { - console.log('--user is not connected to voice server') - } - - }; - const userListObserver = new MutationObserver(userListChangeCallback); - userListObserver.observe(userList, userListconfig); - `) -} - function userMuteDeafenListener(webview) { webview.executeJavaScript(` const userMuteDeafen = document.getElementsByClassName("container-3baos1")[0] @@ -179,7 +159,7 @@ onload = () => { `) webview.executeJavaScript(` - let dlButton = document.getElementsByClassName("listItem-2P_4kh"); + let dlButton = document.querySelectorAll('[aria-label="Download Apps"]') t = setInterval(function(){ if(dlButton.length != 0) { console.log("--discord-load-complete") @@ -205,15 +185,14 @@ onload = () => { // Send commands to preload.js webview.addEventListener('console-message', (e) => { - - if (e.message === "--user is connected to voice server") { + 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 === "--user is not connected to voice server") { + if (e.message.includes("RTC media connection state: DISCONNECTED")) { console.log("Disconnected from server") window.postMessage({ type: "disconnected"}, "*") isConnectedToVoiceServer = false @@ -231,8 +210,6 @@ onload = () => { // Execute JS into the webview after login if (e.message === "--discord-load-complete") { - webview.executeJavaScript(`document.getElementsByClassName("listItem-2P_4kh")[document.getElementsByClassName("listItem-2P_4kh").length - 1].style.display = 'none';`) // Remove download button - userListChangeListener(webview) userMuteDeafenListener(webview) removeBloat(webview) }