Skip to content

Instantly share code, notes, and snippets.

@Caltrop256
Last active June 5, 2024 17:18
Show Gist options
  • Save Caltrop256/349f399a59e8035d17205ba6d9d4c295 to your computer and use it in GitHub Desktop.
Save Caltrop256/349f399a59e8035d17205ba6d9d4c295 to your computer and use it in GitHub Desktop.
Gets your discord user token and stores it. Paste this code into the console, make sure you have cache disabled (network -> disable cache)
new Promise(function (resolve) {
const iframe = document.createElement('iframe');
window.document.head.append(iframe);
const pd = Object.getOwnPropertyDescriptor(iframe.contentWindow, 'localStorage');
Object.defineProperty(window, 'localStorage', pd);
iframe.remove();
if (window.localStorage.__token) {
resolve(window.localStorage.__token);
} else {
window.__request = window.XMLHttpRequest;
window.XMLHttpRequest = class __Interceptor extends window.__request {
constructor() {
super(...arguments);
this._reqHead = this.setRequestHeader;
this.setRequestHeader = function (name, body) {
this._reqHead(name, body);
if (name === "Authorization") {
window.localStorage.__token = body;
window.XMLHttpRequest = window.__request;
delete window.__request;
resolve(body);
}
}.bind(this);
};
};
alert("Please switch channel to obtain token!");
}
}).then(function (token) {
console.log('Token:', token)
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment