#๐Ÿ“œ-js-snippets

1 messages ยท Page 1 of 1 (latest)

wicked lance
#

find module by id: Vencord.Webpack.wreq(MODULE_ID)

cobalt bluff
#
var random = Math.random

Math = new Proxy({}, { get: () => random })```
Try and see what happens (It might send invalid api requests)
warped cairn
#

why

#

actually nvm can you send a screenshot im really curious now

warped cairn
#

i dont have access

#

how am I not cool

#

๐Ÿ˜ 

next ether
next ether
#

and i had to manually kill discord

runic obsidian
#

LMAO

narrow kite
#

Cookie Clicker but better

document.querySelectorAll("*").forEach(x => x.onclick = (e) => {
    e.stopPropagation()
    x.counter ||= 0
    x.innerText = `You clicked ${++x.counter} times!`
    x.style.color = "var(--text-normal)"
})
silent ember
rough rock
#
{
    const themeCustom = Array.from(document.styleSheets).find(ss => ss.cssRules[0]?.selectorText === '.theme-custom').cssRules[0]
    const vars = Array.from(themeCustom.style)
    const dummy = document.createElement('div')
    document.head.appendChild(dummy)
    const varMap = new Map()
    for (const v of vars) {
        dummy.style.backgroundColor = `var(${v})`
        const color = getComputedStyle(dummy).getPropertyValue('background-color')
        if (!color.startsWith('rgb(')) continue
        varMap.set(v, color.slice(4, -1))
    }
    dummy.remove()
    const cssBody = [...varMap.entries()].map(([k, v]) => `${k}-rgb:${v}`).join(';')
    const kFix = 'theme-primary-fix'
    const fixStyle = document.getElementById(kFix) ?? document.createElement('style')
    fixStyle.innerText = `.theme-custom{${cssBody}}`
    fixStyle.id = kFix
    if (!fixStyle.isConnected) document.head.appendChild(fixStyle)
}```
#

fix some elements when using theme experiment. eg: hovered/selected channels, cards (like in the plugin tab)

charred current
#

if for some reason this happens to you #๐ŸงŠ-off-topic-iceman-only message

Vencord.Settings.useQuickCss = false //disable quickcss

console.log(Vencord.Settings.themeLinks.join("\n")) //backup for noobs
Vencord.Settings.themeLinks = [] //unset themes
maiden spindle
#

Join any HypeSquad house without doing the quiz

let desiredHouse = "brilliance"; // Put here the name of the house you want

let HOUSES = {
    bravery: "HOUSE_1",
    brilliance: "HOUSE_2",
    balance: "HOUSE_3"
};

Vencord.Webpack.findByProps("joinHypeSquadOnline", "leaveHypeSquadOnline").joinHypeSquadOnline({ houseID: HOUSES[desiredHouse.toLowerCase()] });

Leave HypeSquad

Vencord.Webpack.findByProps("joinHypeSquadOnline", "leaveHypeSquadOnline").leaveHypeSquadOnline()
narrow kite
#

Starts the debugger after 2s which freezes the entire app. Useful for inspecting hover elements like this without them closing so you can get their css classes and stuff. You can change the 2000 to increase or decrease the timer, 5000 is 5 seconds for example

setTimeout(() => { debugger }, 2000)
narrow kite
#

Get all the funny badges (only shows for you, not for other users (duh))

(() => {
    const flags = Vencord.Webpack.findByProps("ACTIVE_DEVELOPER", "PARTNER", "MFA_SMS");
    const allFlags = ["ACTIVE_DEVELOPER", "BUG_HUNTER_LEVEL_1", "BUG_HUNTER_LEVEL_2", "CERTIFIED_MODERATOR", "HYPESQUAD", "HYPESQUAD_ONLINE_HOUSE_1", "HYPESQUAD_ONLINE_HOUSE_2", "HYPESQUAD_ONLINE_HOUSE_3", "PARTNER", "STAFF", "PREMIUM_EARLY_SUPPORTER", "VERIFIED_DEVELOPER"].reduce((acc, curr) => acc + flags[curr], 0);
    Vencord.Webpack.Common.UserStore.getCurrentUser().flags = allFlags;
})()

restart Discord to undo

maiden spindle
#

Apply the secret theme

Vencord.Webpack.findByCode(".backgroundGradientPresetId,")({ backgroundGradientPresetId: 16, theme: "light" });
narrow kite
#

Become schizophrenic

run stop() to stop

(() => {
    const { GuildMemberStore, FluxDispatcher, SelectedChannelStore } = Vencord.Webpack.Common;
    
    const i = setInterval(() => FluxDispatcher.dispatch({
        type: "TYPING_START",
        channelId: SelectedChannelStore.getChannelId(),
        userId: GuildMemberStore.getMemberIds(Vencord.Util.getCurrentGuild().id).sort(() => Math.random() - 0.5)[0]
    }), 5000)
    return window.stop = () => clearInterval(i)
})()
narrow kite
# narrow kite Get all the funny badges (only shows for you, not for other users (duh)) ```js (...

Since discord broke the old snippet...

Get all the silly little badges Part 2
(and yes we have to hardcode all the badges here, Discord now sends them from the API)
https://cdn.discordapp.com/attachments/1033680203433660458/1098431118631522364/image.png

(() => {
    const store = Vencord.Webpack.findStore("UserProfileStore");
    const original = store.getUserProfile;
    store.getUserProfile = function (id) {
        const r = original.apply(this, arguments);
        if (r && id === Vencord.Webpack.Common.UserStore.getCurrentUser()?.id)
            r.badges = [{id:"hypesquad_house_1",description:"HypeSquad Bravery",icon:"8a88d63823d8a71cd5e390baa45efa02",link:"https://discord.com/settings/hypesquad-online"},{id:"hypesquad_house_2",description:"HypeSquad Brilliance",icon:"011940fd013da3f7fb926e4a1cd2e618",link:"https://discord.com/settings/hypesquad-online"},{id:"hypesquad_house_3",description:"HypeSquad Balance",icon:"3aa41de486fa12454c3761e8e223442e",link:"https://discord.com/settings/hypesquad-online"},{id:"hypesquad",description:"HypeSquad Events",icon:"bf01d1073931f921909045f3a39fd264",link:"https://discord.com/hypesquad"},{id:"early_supporter",description:"Early Supporter",icon:"7060786766c9c840eb3019e725d2b358",link:"https://discord.com/settings/premium"},{id:"premium",description:"Subscriber since 30 Jan 2020",icon:"2ba85e8026a8614b640c2837bcdfe21b",link:"https://discord.com/settings/premium"},{id:"active_developer",description:"Active Developer",icon:"6bdc42827a38498929a4920da12695d9",link:"https://support-dev.discord.com/hc/en-us/articles/10113997751447"},{id:"verified_developer",description:"Early Verified Bot Developer",icon:"6df5892e0f35b051f8b61eace34f4967"},{id:"certified_moderator",description:"Moderator Programmes Alumni",icon:"fee1624003e2fee35cb398e125dc479b",link:"https://discord.com/safety"},{id:"bug_hunter_level_2",description:"Discord Bug Hunter",icon:"848f79194d4be5ff5f81505cbd0ce1e6",link:"https://support.discord.com/hc/en-us/articles/360046057772-Discord-Bugs"},{id:"bug_hunter_level_1",description:"Discord Bug Hunter",icon:"2717692c7dca7289b35297368a940dd0",link:"https://support.discord.com/hc/en-us/articles/360046057772-Discord-Bugs"},{id:"partner",description:"Partnered Server Owner",icon:"3f9748e53446a137a052f3454e2de41e",link:"https://discord.com/partners"},{id:"staff",description:"Discord Staff",icon:"5e74e9b61934fc1f67c65515d1f7e60d",link:"https://discord.com/company"}]
        return r;
    }
})()
narrow kite
#

How do I run these?

  • Press ctrl + shift + i to open devtools
  • Click the console tab on the top
  • Focus the input box (right of the blue >) if necessary
  • Paste and hit enter

โš ๏ธ Do not run any script you do not trust. Running malicious scripts here has the potential to steal your account or similar โš ๏ธ

marble minnow
#

lurk a guild via id for the rest of your session, including losing focus of guild (mostly stolen) ```js
function lurk(id) {
Vencord.Webpack.findByProps("joinGuild").joinGuild(id, {lurker: true})
.then(() => {setTimeout(() => patchGuild(id), 100)})
.catch(() => {throw new Error("Guild is not lurkable")});
}

function patchGuild(id) {
Vencord.Webpack.findByProps("getGuildsTree").getGuildsTree().root.children.unshift({type: "guild", id, unavailable: false, children: []});
Vencord.Webpack.findByProps("getGuildCount").getGuild(id).joinedAt = new Date;
Vencord.Webpack.findByProps("lurkingGuildIds").lurkingGuildIds().pop();
Vencord.Webpack.findByProps("joinGuild").transitionToGuildSync(id);
}

lurk("guildid");

narrow kite
#

Open anyone's profile by user id even if you don't share a server. Useful for looking up users by id

Just change the id to your desired id. Make sure to keep the ", they're important

Vencord.Util.openUserProfile("343383572805058560")
brittle shoal
#

Download a server's emojis as a zip file

async function zipServerEmojis(id) {
    await fetch("https://unpkg.com/fflate@0.8.0").then(r => r.text()).then(eval);
    const emojis = Vencord.Webpack.Common.EmojiStore.getGuilds()[id]?.emojis;
    if (!emojis) {
        return console.log("Server not found!");
    }

    const fetchEmojis = async e => {
        const filename = e.id + (e.animated ? ".gif" : ".png");
        const emoji = await fetch("https://cdn.discordapp.com/emojis/" + filename + "?size=512&quality=lossless" ).then(res => res.blob());
        return { file: new Uint8Array(await emoji.arrayBuffer()), filename };
    };
    const emojiPromises = emojis.map(e => fetchEmojis(e));

    Promise.all(emojiPromises)
        .then(results => {
            const emojis = fflate.zipSync(Object.fromEntries(results.map(({ file, filename }) => [filename, file])));
            const blob = new Blob([emojis], { type: "application/zip" });
            const link = document.createElement("a");
            link.href = URL.createObjectURL(blob);
            link.download = `emojis-${id}.zip`;
            link.click();
            link.remove();
        })
        .catch(error => {
            console.error(error);
        });
}
zipServerEmojis("SERVER ID HERE");
real tinsel
#

Clear a draft for a channel you cant send messages in anymore (discord stupidity)

await Vencord.Webpack.Common.FluxDispatcher.dispatch({
  type: "DRAFT_CLEAR", 
  channelId: CHANNEL_ID_HERE, 
  draftType: 0 /* Change 0 to 2 if its a thread starter message */
})

alternatively/additionally enable react devtools in settings and delete the text that way, it's saved locally

ripe wolf
#

Open anyone s profile by user id even if

cobalt bluff
#
await Vencord.Webpack.Common.FluxDispatcher.dispatch({
    type: "MESSAGE_CREATE",
    channelId: Vencord.Util.getCurrentChannel().id,
    message: {
        author: Vencord.Webpack.Common.UserStore.getUser("287555395151593473"),
        content: "",
        embeds: [{
            type: "safety_policy_notice",
            title: "",
            description: "",
            fields: [
                {
                    name:"incident_time",
                    value:3
                },
                {
                    name:"classification_id",
                    value:3
                }
            ]
        }],
        channel_id: Vencord.Util.getCurrentChannel().id,
        id: Vencord.Webpack.Common.SnowflakeUtils.fromTimestamp(Date.now())

    }
})

create a brilliant looking local message

distant goblet
#

Discord is yours

document.body.contentEditable = "true";
distant goblet
#

Bad code:

function getAppIcons() {
    const { findModuleId, wreq } = Vencord.Webpack;
    const resolvedModule = wreq(findModuleId("APP_ICON_HOLO_WAVES}"));
    const list = Object.values(resolvedModule).find(Array.isArray);
    return list.map(icon => icon.id + ": https://discord.com" + icon.iconSource).join("\n");
}

console.log(getAppIcons()); // or whatever.

here is the current output (it is probably subject to change):

whole ibex
#

Migrate TextReplace data to another install. Run this in the console of the old one, then copy the output to the new one, and then reload.

console.log(`await Vencord.Api.DataStore.set("TextReplace_rulesString", ${JSON.stringify(await Vencord.Api.DataStore.get('TextReplace_rulesString'))})`)
console.log(`await Vencord.Api.DataStore.set("TextReplace_rulesRegex", ${JSON.stringify(await Vencord.Api.DataStore.get('TextReplace_rulesRegex'))})`)```
crude vapor
sand parcel
#
guild = Vencord.Webpack.Common.SelectedGuildStore.getGuildId()
channel = Vencord.Webpack.Common.SelectedChannelStore.getVoiceChannelId()
user_id = Vencord.Webpack.Common.UserStore.getCurrentUser().id
setInterval(() => Vencord.Webpack.Common.RestAPI.post({url: "/quests/1227395355193118750/heartbeat",body:{stream_key: `guild:${guild}:${channel}:${user_id}`}}), 60000)

ez avatar decoration (you need to enroll first)

narrow kite
#

cause dziurwa too dum to add instructions:

dont switch channels between steps 1-3
0) accept the quest https://canary.discord.com/quests/1227395355193118750

  1. join a voice channel on some server
  2. start streaming anything, doesnt matter what
  3. run snippet
  4. wait 15 minutes and quest should be done
  5. restart discord once to stop it from continously posting
real tinsel
oak creek
woven geode
#
function benchSelector(selector) {
  console.time(`100k iterations of ${selector}`)
  for (let i = 0; i < 100000; i++)
    document.querySelectorAll(selector)
  console.timeEnd(`100k iterations of ${selector}`)
  console.log(`${document.querySelectorAll(selector).length} matches`)
}
bold scarab
#

a filter for deuteranopia colorblindness for color-correcting things inside discord

(more colorblind filter types inside thread)

https://cdn.discordapp.com/attachments/1128774033249403101/1249110740657377450/image.png?ex=66661c87&is=6664cb07&hm=89cba90156601eb2518a437b41404bddd03e2ad4dc1bc396257ae791b8ce6f89&

(function() {
    var svgNS = "http://www.w3.org/2000/svg";
    var svg = document.createElementNS(svgNS, "svg");
    svg.setAttribute("version", "1.1");
    svg.style.display = "none";

    // actually creates the filter
    var filter = document.createElementNS(svgNS, "filter");
    filter.setAttribute("id", "deuteranopia-filter");

    var feColorMatrix = document.createElementNS(svgNS, "feColorMatrix");
    feColorMatrix.setAttribute("type", "matrix");
    feColorMatrix.setAttribute("values", "0.625, 0.375, 0, 0, 0, 0.7, 0.3, 0, 0, 0, 0, 0.3, 0.7, 0, 0, 0, 0, 0, 1, 0");

    filter.appendChild(feColorMatrix);

    svg.appendChild(filter);

    document.body.appendChild(svg);

    // applies the filter
    document.body.style.filter = "url(#deuteranopia-filter)";
})();

bold scarab
#

a filter for deuteranopia colorblindness

bold scarab
#

adds a shortcut (ctrl+shift+s) to activate/deactivate the silent typing plugin ||(requires the plugin obviously)||

document.addEventListener('keydown', function(event) {
    if (event.ctrlKey && event.shiftKey && event.key === 'S') {
        event.preventDefault(); // prevents the default action
        const buttonDisable = document.querySelector('button[aria-label="Disable Silent Typing"]');
        const buttonEnable = document.querySelector('button[aria-label="Enable Silent Typing"]');
        
        if (buttonDisable) {
            buttonDisable.click();
        } else if (buttonEnable) {
            buttonEnable.click();
        } else {
            console.log('no button, no click');
        }
    }
});
bold scarab
#

adds a flying nyan cat to your discord ๐Ÿฑ๐ŸŒˆ
https://media.discordapp.net/attachments/644220552554217506/1249591879029358702/image.png?ex=6667dca0&is=66668b20&hm=8c584ae721fef11113a0897d2abc511b57ff28de024744baf0bfa520831f9c02&=&format=webp&quality=lossless

// summons nyan
const nyanCat = document.createElement('div');
nyanCat.id = 'nyan-cat';
document.body.appendChild(nyanCat);

const nyanCatStyles = `
    #nyan-cat {
        position: absolute;
        width: 150px;
        height: 75px;
        background-image: url('https://static.wikia.nocookie.net/nyancat/images/b/b9/OriginalNyan.gif');
        background-size: contain;
        background-repeat: no-repeat;
        z-index: 9999;
    }
`;

const styleSheet = document.createElement('style');
styleSheet.type = 'text/css';
styleSheet.innerText = nyanCatStyles;
document.head.appendChild(styleSheet);

// sets initial position and velocity
let posX = Math.random() * (window.innerWidth - 150);
let posY = Math.random() * (window.innerHeight - 75);
let velocityX = 2;
let velocityY = 2;

function updateNyanCatPosition() {
    posX += velocityX;
    posY += velocityY;

    // makes it bouncy
    if (posX <= 0 || posX >= window.innerWidth - 150) {
        velocityX = -velocityX;
    }
    if (posY <= 0 || posY >= window.innerHeight - 75) {
        velocityY = -velocityY;
    }

    nyanCat.style.transform = `translate(${posX}px, ${posY}px)`;

    requestAnimationFrame(updateNyanCatPosition);
}

// starts the animation
requestAnimationFrame(updateNyanCatPosition);
oak creek
#

nyan cat snippet

brittle beacon
#

Since Discord is too lazy to put this request in the VC websocket.

const voiceID = "The voice call's channelID";
const guildID = "The guild ID where the soundboard originates from";
// You can get the soundboard ID by going into requests, sending the soundboard you want to play, then clicking on the request and getting the 'sound_id' field of the body/JSON
const soundboardID = "The soundboard ID of the sound you want to play.";

function sendSoundboard(voiceID, soundboardID, guildID) {
    Vencord.Webpack.Common.RestAPI.post({
        url: Constants.Endpoints.SEND_SOUNDBOARD_SOUND(voiceID),
        body: {
            sound_id: soundboardID,
            source_guild_id: guildID,
        },
    });
};

sendSoundboard(voiceID, soundboardID, guildID);

You can also annoying your friend by doing this:

setInterval(() => {
    sendSoundboard(...);
}, 1000)
fathom kernel
#

Fixes 401 Auth error in cloud sync by "turning it off and on again"

(() => {
    Vencord.Settings.cloud.url = 'https://api.placeholder.dev/'
    Vencord.Settings.cloud.authenticated = false
 })()
(() => {
    Vencord.Settings.cloud.url = 'https://api.vencord.dev/'
    Vencord.Settings.cloud.authenticated = true
 })()

Run them in order :3

brittle beacon
#

Group Chat Ringing

In case someone is spam ringing you in a GC, you can use the API to stop the ringing:

RestAPI.post({
    url: Constants.Endpoints.CALL_STOP_RINGING("GROUP_DM_ID"),
    body: {}
})

It's better to beat them at their own game then leaving the GC which to them might mean "I give up". You can also set this up at a interval so it automatically declines

visual ruin
#

Fixes 401 Auth error in cloud sync by "

violet cypress
cyan pike
#

Ctrl + Left Click to translate and untranslate a hovered chat message (Requires Translate Plugin)

let translateActionTaken = false;
let ctrlPressed = false;

const simulateLeftClick = (element) => {
    if (element) {
        element.dispatchEvent(new MouseEvent('click', { bubbles: true, cancelable: true, view: window, button: 0 }));
    }
};

document.addEventListener('keydown', (event) => {
    if (event.key === 'Control') {
        ctrlPressed = true;
    }
});

document.addEventListener('keyup', (event) => {
    if (event.key === 'Control') {
        ctrlPressed = false;
    }
});

document.addEventListener('mousedown', (event) => {
    if (event.button === 0 && ctrlPressed) { 
        event.preventDefault();

        const messageContainer = document.querySelector('[class*=cozyMessage_]:hover');
        if (!messageContainer) return;

        const dismissButton = messageContainer.querySelector('.vc-trans-dismiss');
        if (dismissButton) {
            simulateLeftClick(dismissButton);
            translateActionTaken = false;
            return;
        }

        const translateButton = messageContainer.querySelector('[aria-label="Translate"]');
        if (translateButton) {
            simulateLeftClick(translateButton);
            translateActionTaken = !translateActionTaken;
        }
    }
});```
foggy stirrup
#

spongbob

cyan pike
#

Want to quickly access the Quick CSS editor? Just press Ctrl + Alt + Q or โŒ˜ + Option + Q if you're on the Mac, and it will open instantly!

document.addEventListener('keydown', function(event) {
  if ((event.ctrlKey || event.metaKey) && event.altKey && event.key === 'q') {
    VencordNative.quickCss.openEditor();
  }
});
acoustic idol
#

Sticker zip downloads via zip

lethal crown
#

Shows how many guilds you're in (as a number in console)

Vencord.Webpack.findByProps("getGuildCount").getGuildCount()
regal jasper
#

export all your favorite GIFs to JSON in your clipboard

Without metadata (order, format, dimensions)

copy(JSON.stringify(Object.entries(Vencord.Webpack.findStore("UserSettingsProtoStore").frecencyWithoutFetchingLatest.favoriteGifs.gifs).map(([src,{src:proxy}])=>({src,proxy}))))

With metadata

copy(JSON.stringify(Object.entries(Vencord.Webpack.findStore("UserSettingsProtoStore").frecencyWithoutFetchingLatest.favoriteGifs.gifs).map(([src,{src:proxy,...rest}])=>({src,proxy,...rest}))))
shut plover
#

importing gifs from json

cyan pike
#

Effortlessly fast-forward through quest videos that offer rewards like Orbs, Decorations and Game Bundles.

document.querySelectorAll('[class^="videoCont_"] video').forEach(v => {
  v.playbackRate = 16; // raises the playback speed to the highest of it's ability
  v.volume = 0; // lowers the volume to avoid ear damage
  v.play(); // attempts to play the video if it isn't already
});
bold scarab
#

(for vesktop users)
removes the "Discord |" from vesktop's title

const cleanTitle = () => {
  if (document.title.startsWith("Discord - ") || document.title.startsWith("Discord | ")) {
    document.title = document.title.replace(/^Discord\s[-|]\s/, '').trim();
  }
};

cleanTitle();

const titleObserver = new MutationObserver(cleanTitle);
const titleElement = document.querySelector('title');
titleObserver.observe(titleElement, { childList: true });

example: https://f.feridinha.com/ecklk.png

rapid anchor
#

Dom manip

urban gull
#

Custom game IDs for server profile

honest nimbus
#

Copy user's profile colors

const { getUserProfile } = Vencord.Webpack.findByProps("getUserProfile");

// change user ID below
const userId = "123";
const profile = getUserProfile(userId);

if (!profile?.themeColors?.length || profile.themeColors.length < 2) {
  console.log("No valid theme colors found");
} else {
  const [primary, secondary] = profile.themeColors;
  const primaryHex = primary.toString(16).padStart(6, "0");
  const secondaryHex = secondary.toString(16).padStart(6, "0");

  console.log("Primary Color:", `#${primaryHex}`);
  console.log("Secondary Color:", `#${secondaryHex}`);
}