AO3: Add Confirmation before Posting Works

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

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 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) {}