Created
March 15, 2025 21:51
-
-
Save barretts/0b70991a7afcb84bfb8106053f77f646 to your computer and use it in GitHub Desktop.
mute all discord channels "Until I turn it back on"
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
// expand all folders before running and | |
// zoom out so all guild icons are visible | |
function extractAndProcessIds() { | |
const elements = document.querySelectorAll('[data-list-item-id^="guildsnav___"]'); | |
const uniqueIdsArray = Array.from(elements) | |
.map(el => el.getAttribute('data-list-item-id').replace('guildsnav___', '')) | |
.filter(id => !isNaN(id)) | |
.reduce((acc, id) => { | |
if (!acc.includes(id)) acc.push(id); | |
return acc; | |
}, []); | |
return uniqueIdsArray; | |
} | |
const guildIds = extractAndProcessIds(); | |
async function fetchData(value) { | |
try { | |
const response = await fetch("https://discord.com/api/v9/users/@me/guilds/settings", { | |
"credentials": "include", | |
"headers": "BRING_YOU_OWN_HEADERS_CHECK_DEV_CONSOLE_FOR_SESSION_INFO", | |
"referrer": "https://discord.com/channels/1245221993746399232/1284730423808622642", | |
"body": "{\"guilds\":{\""+value+"\":{\"muted\":true,\"mute_config\":{\"selected_time_window\":-1,\"end_time\":null}}}}", | |
"method": "PATCH", | |
"mode": "cors" | |
}); | |
if (!response.ok) { | |
throw new Error('Network response was not ok ' + response.statusText); | |
} | |
const data = await response.json(); | |
return data; | |
} catch (error) { | |
console.error('There has been a problem with your fetch operation:', error); | |
} | |
} | |
function sleep(ms) { | |
return new Promise(resolve => setTimeout(resolve, ms)); | |
} | |
async function processArray(array) { | |
for (const value of array) { | |
const result = await fetchData(value); | |
console.log(`Data for ${value}:`, result); | |
await sleep(500); | |
} | |
} | |
processArray(guildIds); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment