Skip to content

Instantly share code, notes, and snippets.

@davidpaulhunt
Last active May 18, 2025 06:08
Show Gist options
  • Save davidpaulhunt/833300626572dfbbe488a9b7b7a0815c to your computer and use it in GitHub Desktop.
Save davidpaulhunt/833300626572dfbbe488a9b7b7a0815c to your computer and use it in GitHub Desktop.
Quickly delete all of your private feeds
function deleteFeeds() {
async function deleteFeed(path, name) {
const csrf_token = document.cookie
.split('; ')
.find(c => c.startsWith('csrf_token='))
.split('=')[
1
];
const result = await fetch(
"https://www.reddit.com/svc/shreddit/graphql",
{
method: 'POST',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json'
},
body: JSON.stringify({
"operation": "CustomFeedDelete",
"variables": {
"input": {
"label": path
}
},
"csrf_token": csrf_token,
}),
}
)
if (result.ok) {
console.info(`Left ${name}`);
} else {
console.error(`Oops could not leave ${name}`, result.status, result.body);
}
}
function randomDelayMs() {
return Math.floor(Math.random() * (3500 - 1000 + 1)) + 1000;
}
const parent = document.querySelector("left-nav-multireddits-controller");
const list = JSON.parse(parent.initialStateJSON)
list.forEach((obj) => {
setTimeout(() => {
(() => {
try {
console.log(`Leaving ${obj.displayName}`)
deleteFeed(obj.path, obj.displayName);
} catch (error) {
console.error("oops", error)
}
})()
}, randomDelayMs());
})
}
function leaveAllCommunities() {
async function quitCommunity(subredditId, name) {
const csrf_token = document.cookie
.split('; ')
.find(c => c.startsWith('csrf_token='))
.split('=')[1];
const result = await fetch(
"https://www.reddit.com/svc/shreddit/graphql",
{
method: 'POST',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json'
},
body: JSON.stringify({
"operation": "UpdateSubredditSubscriptions",
"variables": { "input": { "inputs": [{ "subredditId": subredditId, "subscribeState": "NONE" }] } }, "csrf_token": csrf_token,
}),
}
)
if (result.ok) {
console.info(`Left ${name}`);
} else {
console.error(`Oops could not leave ${name}`, result.status, result.body);
}
}
function randomDelayMs() {
return Math.floor(Math.random() * (3500 - 1000 + 1)) + 1000;
}
const parent = document.querySelector("left-nav-communities-controller");
const communities = JSON.parse(parent.initialStateJSON);
communities.forEach((community) => {
const id = community.id;
const name = community.prefixedName;
setTimeout(() => {
(() => {
try {
console.log(`Leaving ${name}`)
quitCommunity(id, name);
} catch (error) {
console.error("oops", error)
}
})()
}, randomDelayMs());
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment