AO3: Add Confirmation before Posting Works

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

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name          AO3: Add Confirmation before Posting Works
// @author        Quihi
// @version       1.0
// @namespace     https://greasyfork.org/en/users/812553-quihi
// @description   Adds a confirmation to the "Post" button on Archive of Our Own.
// @match         https://archiveofourown.org/*works*/*
// @match     	  https://www.archiveofourown.org/*works*/*
// ==/UserScript==

// when posting a work
try {
  document.getElementById("work-form").querySelectorAll("input[name='post_button']")[0].setAttribute("data-confirm", "Are you sure you're ready to post this?");
}
catch (error) {}

// when posting a chapter
try {
  document.getElementById("chapter-form").querySelectorAll("input[name='post_without_preview_button']")[0].setAttribute("data-confirm", "Are you sure you're ready to post this?");
}
catch (error) {}

// when editing a draft
try {
  document.getElementById("previewpane").querySelectorAll("input[name='post_button']")[0].setAttribute("data-confirm", "Are you sure you're ready to post this?");
}
catch (error) {}

// other times editing a chapter
try {
  document.getElementsByClassName("edit_chapter")[0].querySelectorAll("input[name='post_button']")[0].setAttribute("data-confirm", "Are you sure you're ready to post this?");
}
catch (error) {}

// other times editing a chapter
try {
  document.getElementsByClassName("edit_chapter")[0].querySelectorAll("input[name='update_button']")[0].setAttribute("data-confirm", "Are you sure you're ready to post this?");
}
catch (error) {}

// other times editing a work
try {
  document.getElementsByClassName("edit_work")[0].querySelectorAll("input[name='update_button']")[0].setAttribute("data-confirm", "Are you sure you're ready to post this?");
}
catch (error) {}

// on the drafts page
try {
  let draftspage = document.getElementsByClassName("works-drafts dashboard region")[0];
  let buttons = draftspage.getElementsByClassName("actions");
  for (let i = 0; i < buttons.length; i++) {
    buttons[i].children[3].children[0].setAttribute("data-confirm", "Are you sure you're ready to post this?");
  }
}
catch (error) {}