AO3: Add Confirmation before Posting Works

Adds a confirmation to the "Post" button on Archive of Our Own.

  1. // ==UserScript==
  2. // @name AO3: Add Confirmation before Posting Works
  3. // @author Quihi
  4. // @version 1.0
  5. // @namespace https://greasyfork.org/en/users/812553-quihi
  6. // @description Adds a confirmation to the "Post" button on Archive of Our Own.
  7. // @match https://archiveofourown.org/*works*/*
  8. // @match https://www.archiveofourown.org/*works*/*
  9. // ==/UserScript==
  10.  
  11. // when posting a work
  12. try {
  13. document.getElementById("work-form").querySelectorAll("input[name='post_button']")[0].setAttribute("data-confirm", "Are you sure you're ready to post this?");
  14. }
  15. catch (error) {}
  16.  
  17. // when posting a chapter
  18. try {
  19. document.getElementById("chapter-form").querySelectorAll("input[name='post_without_preview_button']")[0].setAttribute("data-confirm", "Are you sure you're ready to post this?");
  20. }
  21. catch (error) {}
  22.  
  23. // when editing a draft
  24. try {
  25. document.getElementById("previewpane").querySelectorAll("input[name='post_button']")[0].setAttribute("data-confirm", "Are you sure you're ready to post this?");
  26. }
  27. catch (error) {}
  28.  
  29. // other times editing a chapter
  30. try {
  31. document.getElementsByClassName("edit_chapter")[0].querySelectorAll("input[name='post_button']")[0].setAttribute("data-confirm", "Are you sure you're ready to post this?");
  32. }
  33. catch (error) {}
  34.  
  35. // other times editing a chapter
  36. try {
  37. document.getElementsByClassName("edit_chapter")[0].querySelectorAll("input[name='update_button']")[0].setAttribute("data-confirm", "Are you sure you're ready to post this?");
  38. }
  39. catch (error) {}
  40.  
  41. // other times editing a work
  42. try {
  43. document.getElementsByClassName("edit_work")[0].querySelectorAll("input[name='update_button']")[0].setAttribute("data-confirm", "Are you sure you're ready to post this?");
  44. }
  45. catch (error) {}
  46.  
  47. // on the drafts page
  48. try {
  49. let draftspage = document.getElementsByClassName("works-drafts dashboard region")[0];
  50. let buttons = draftspage.getElementsByClassName("actions");
  51. for (let i = 0; i < buttons.length; i++) {
  52. buttons[i].children[3].children[0].setAttribute("data-confirm", "Are you sure you're ready to post this?");
  53. }
  54. }
  55. catch (error) {}