Last active
March 8, 2025 12:06
-
-
Save DevGod100/6b1c93379071804b54995e190b99623c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { launch } = require("puppeteer"); | |
(async () => { | |
// Launch puppeteer instance | |
console.log("Launching Puppeteer browser..."); | |
const browser = await launch({ | |
headless: "new" | |
}); | |
//In the near future `headless: true` will default to the new Headless mode headless: "new" | |
const page = await browser.newPage(); | |
const discordToken = process.env.DISCORD_TOKEN; // Your Discord Token, How To Get Your Discord Token -> https://www.youtube.com/watch?v=YEgFvgg7ZPI&ab_channel=GaugingGadgets | |
//Added env variable to secure token | |
// Local Storage error with Puppeteer, found bypass, CREDIT: https://gist.github.com/zelbov/58e9fbbe5157bf61067d2693118dd09a | |
const bypassLocalStorageOverride = (page) => | |
page.evaluateOnNewDocument(() => { | |
// Preserve localStorage as separate var to keep it before any overrides | |
let __ls = localStorage; | |
// Restrict closure overrides to break global context reference to localStorage | |
Object.defineProperty(window, "localStorage", { | |
writable: false, | |
configurable: false, | |
value: __ls, | |
}); | |
}); | |
console.log( | |
"Redirecting to https://discord.com/app ... (May take a few seconds)" | |
); | |
// Calling function before storing token into Discord so that errors don't occur | |
bypassLocalStorageOverride(page); | |
await page.goto("https://discord.com/app"); | |
// Setting token into Discord Local Storage (Don't worry it's not being sent/stored anywhere, this is how Discord does it) | |
await page.evaluate((token) => { | |
localStorage.setItem("token", `"${token}"`); | |
}, discordToken); | |
// Navigate to a page where you want to use the local storage value | |
await page.goto(""); // The discord channel / App Authorization that you want to log into Discord for... | |
console.log("Successfully logged in..."); | |
await page.waitForTimeout(5000); // Wait for page to load | |
// Do whatever you want here afterwards, I just decided to take a screenshot for proof | |
await page.screenshot({ path: "output.png" }); | |
// Ending proccess | |
await browser.close(); | |
})(); |
Hi, I got an error when applied your code
Redirecting to https://discord.com/app ... (May take a few seconds)
ProtocolError: Protocol error (Page.navigate): Cannot navigate to invalid URL
ProtocolError: Protocol error (Page.navigate): Cannot navigate to invalid URL
await page.goto("");
Dont leave this empty.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I found this gist here:
https://gist.github.com/listingclown3/7d5ac6e42a0cdc5ce85f28ededa3106b
Made my own changes and posted for myself.