Skip to content

Instantly share code, notes, and snippets.

@stephenlacy
Created November 12, 2024 22:42
Show Gist options
  • Save stephenlacy/310abaec04dcb5a627c1a08d4a14be6f to your computer and use it in GitHub Desktop.
Save stephenlacy/310abaec04dcb5a627c1a08d4a14be6f to your computer and use it in GitHub Desktop.
Remove Reddit votes from /user/<username>/downvoted/ and /user/<username>/upvoted/

Remove Reddit upvotes and downvotes

  • Navigate to /user/<username>/downvoted/ or /user/<username>/upvoted/
  • Scroll the entire page loading posts in view.
  • Open your browser developer console.
  • Enter the script and run.
  • Reload the page and scroll to the bottom to load more.
function findAndClickUpvoteButtons() {
const isUpvote = window.location.href.indexOf("upvoted") !== -1;
const customElements = document.querySelectorAll("*");
let shadowHosts = Array.from(customElements).filter((el) => el.shadowRoot);
console.log("Found elements with shadow roots:", shadowHosts.length);
let buttons = [];
shadowHosts.forEach((host) => {
if (host.shadowRoot) {
if (isUpvote) {
const upvotes = host.shadowRoot.querySelectorAll("button[upvote]");
buttons.push(...upvotes);
} else {
const downvotes = host.shadowRoot.querySelectorAll("button[downvote]");
buttons.push(...downvotes);
}
}
});
console.log(`Found ${buttons.length} upvote buttons in shadow DOMs`);
buttons.forEach((button, index) => {
setTimeout(() => {
try {
console.log(`Clicking button ${index + 1}`);
button.click();
} catch (error) {
console.error(`Error clicking button ${index + 1}:`, error);
}
}, index * 500);
});
}
findAndClickUpvoteButtons();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment