Skip to content

Instantly share code, notes, and snippets.

@CertainPerformance
Created September 21, 2022 16:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CertainPerformance/a22ac42a81a7ae80b360910f9864be5b to your computer and use it in GitHub Desktop.
Save CertainPerformance/a22ac42a81a7ae80b360910f9864be5b to your computer and use it in GitHub Desktop.
// Userscript:
const formData = new FormData();
const { fkey } = window.StackExchange.options.user;
formData.append('fkey', fkey);
formData.append('taskTypeId', '3');
// taskResultTypeId possibilities:
// 4: "Delete". 9: "Recommend Deletion".
// Difference between 4 and 9 looks to be cosmetic only. Even if 4 is chosen, no delete votes will be spent via the /task-reviewed/ POST.
// (Without any userscripts, the delete vote that counts and is registered is sent in a separate request)
formData.append('taskResultTypeId', '4');
const initOptions = {
body: formData,
credentials: 'same-origin' as const,
method: 'POST',
};
fetch(`https://stackoverflow.com/review/task-reviewed/${taskId}`, initOptions)
.then( // response and error handling, etc...
// In contrast, Stack Exchange's native request uses XHR rather than fetch to submit the review choice
// and in the form data, in addition to the 3 fields above, also has postCommentId taskResultSubtypeFlags, both of which can be the empty string
// Stack Exchange's native interface for 20k users also sends a delete vote in a *separate* request
// to https://stackoverflow.com/posts/${postId}/vote/10
// with formData of { fkey }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment