Skip to content

Instantly share code, notes, and snippets.

@TheOnlyWayUp
Last active April 11, 2024 07:16
Show Gist options
  • Save TheOnlyWayUp/d428fac359009e51d344e4d02c300883 to your computer and use it in GitHub Desktop.
Save TheOnlyWayUp/d428fac359009e51d344e4d02c300883 to your computer and use it in GitHub Desktop.
Wattpad: VoteAllParts.js

This script votes for all the parts in a Wattpad Story at once.

How to use:

  • Visit the URL of a Story (Ensure this is the page which has a table of contents, the story's tags, ...)
  • Press ctrl + shift + j. This opens the Developer Console.
  • Copy the script in this gist (below, and in script.js. Copy from whatever's convenient.)
  • Paste the code into the Developer Console on the Wattpad Tab, hit enter.
  • Great, you're done!

Star ⭐ this gist if it was useful. Follows to my GitHub Profile are appreciated.

Code:

Also found in the script.js file below.

let story_id = window.location.href.split("story/")[1].split("-")[0];
let part_ids = []

Array.from(document.getElementsByClassName("story-parts")[0].children[0].children).forEach(el => part_ids.push(el.children[0].href.split("com/")[1].split("-")[0]))

part_ids.forEach(part_id => {
  let url = `
https://www.wattpad.com/api/v3/stories/${story_id}/parts/${part_id}/votes`;
  fetch(url, { method: "POST" })
})

Follow Badge


TheOnlyWayUp © 2024

let story_id = window.location.href.split("story/")[1].split("-")[0];
let part_ids = []
Array.from(document.getElementsByClassName("story-parts")[0].children[0].children).forEach(el => part_ids.push(el.children[0].href.split("com/")[1].split("-")[0])) // Extracting Story IDs from Part URLs, which are present in a `ul`.
part_ids.forEach(part_id => {
let url = `
https://www.wattpad.com/api/v3/stories/${story_id}/parts/${part_id}/votes`;
fetch(url, { method: "POST" }) // method: "DELETE" unvotes.
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment