-
Notifications
You must be signed in to change notification settings - Fork 24
Open
Labels
needs looking intoFurther analysis is neededFurther analysis is neededsuggestionNew feature or requestNew feature or request
Description
Collect discord tokens with puppeteer for linux users.
Install these in the same directory as Discord-Backup!
npm install puppeteer @gilgames/discord-detours
Make a javascript file in the same directory as Discord-Backup.
sudo nano index.js
Initial login script
- Place this script in index.js and log in to discord via a non-headless browser:
let puppeteer = require('puppeteer');
const detours = require("@gilgames/discord-detours");
(async () => {
const browser = await puppeteer.launch({ userDataDir: './user_data', headless: false });
const page = await browser.newPage();
await page.goto('https://discord.com/channels/@me');
await page.setViewport({ width: 1080, height: 1024 });
const serializedAPI = detours.serializeModule(detours.api);
await page.evaluate(detours.injectModule, serializedAPI);
const token = await page.evaluate(() => window.discordDetours.findFunctionByName("getToken")());
console.log(token);
await browser.close();
})();- After logging in, replace the initial login script in
index.jswith this one to automatically fetch the token on subsequent runs:
let puppeteer = require('puppeteer');
const detours = require("@gilgames/discord-detours");
(async () => {
const browser = await puppeteer.launch({ userDataDir: './user_data' });
const page = await browser.newPage();
await page.goto('https://discord.com/channels/@me');
await page.setViewport({ width: 1080, height: 1024 });
const serializedAPI = require("@gilgames/discord-detours").serializeModule(require("@gilgames/discord-detours").api);
await page.evaluate(detours.injectModule, serializedAPI);
const token = await page.evaluate(() => window.discordDetours.findFunctionByName("getToken")());
const user_info = await page.evaluate(() => {
const usernameElement = document.querySelector('span[class="text-gray-400 font-semibold"]');
const username = usernameElement ? usernameElement.innerText.split('#')[0] : 'Unknown';
const discriminator = usernameElement ? usernameElement.innerText.split('#')[1] : '0000';
return { username, discriminator };
});
console.log(JSON.stringify({ token, username: user_info.username, discriminator: user_info.discriminator }));
await browser.close();
})();- Modified
fetch_tokens.py
import subprocess
import json
def fetch():
try:
result = subprocess.run(['node', 'index.js'], capture_output=True, text=True, check=True)
token_data = json.loads(result.stdout)
return [[token_data['token'], f"{token_data['username']}#{token_data['discriminator']}", token_data['token'], "Discord"]]
except subprocess.CalledProcessError as e:
print(f"Failed to execute script: {e}")
return []
except json.JSONDecodeError as e:
print(f"Error decoding JSON from script output: {e}")
return []- This will now allow you to automatically backup and restore using the built in choices in main.py without having to manually get your token.
Metadata
Metadata
Assignees
Labels
needs looking intoFurther analysis is neededFurther analysis is neededsuggestionNew feature or requestNew feature or request