Skip to content

Instantly share code, notes, and snippets.

@Ophuscado
Last active September 17, 2022 00:17
Show Gist options
  • Select an option

  • Save Ophuscado/5eb53694d32744caa5e308b7c8dbcabf to your computer and use it in GitHub Desktop.

Select an option

Save Ophuscado/5eb53694d32744caa5e308b7c8dbcabf to your computer and use it in GitHub Desktop.
Reddit automatisation for clicking on upvote and downvote arrows
// The following script is meant to undo upvotes on Reddit using the JavaScript console.
// You can change its behaviour by modifying the following parameters.
async function main() {
// Arrow modes are "upvote" or "downvote".
var mode = "upvote"
// Arrow states are "true" or "false".
// Click on the "true" arrows to disable them.
// Click on the "false" arrows to enable them.
var state = "true"
// Loop over all posts loaded in the page
var items = document.querySelectorAll("button.voteButton");
for (var i = 0; i < items.length; i++) {
if (items[i].getAttribute("aria-label") === mode && items[i].getAttribute("aria-pressed") === state) {
items[i].click();
await new Promise(resolve => setTimeout(resolve, 1000));
}
}
}
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment