ao3 Comment Assist

prompts you to leave a comment when you've already left kudos

目前為 2021-06-13 提交的版本,檢視 最新版本

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

You will need to install an extension such as Tampermonkey to install this script.

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         ao3 Comment Assist
// @version      1.0
// @history      1.0 - basic functionality
// @description  prompts you to leave a comment when you've already left kudos
// @include      /https?://archiveofourown\.org/.*works/\d+/
// @grant        none
// @namespace    https://greasyfork.org/users/36620
// ==/UserScript==

//ACNOWLEDGEMENT: most of the method is cribbed from "ao3 no rekudos" by scriptfairy
//Rest is cribbed from "Change Ao3 Kudos button text to Glory" by AlectoPerdita
//I do not know enough JS to do shit like this on my own
//https://greasyfork.org/en/scripts/406616-ao3-no-rekudos
//https://greasyfork.org/en/scripts/390197-change-ao3-kudos-button-text-to-glory/code

//SETUP//

var assist_type = 0;
    //Set Comment Assist Mode notification type. You can choose from 3 different options.
    //1: A commenting guide for people who have never done it before.
    //2: A short comment prompt that gives you a jumping off point to write your own comment.
    //3: Adds a simple reminder to leave a comment.

var fast_mode = true;
    //Set to "true" to turn on fast posting mode.
    //Hitting "enter" anywhere in the comment field will immediately send your comment.

var lat = 500;
    //Delay in milliseconds, waiting for reply from OTW servers. (Check with CTRL+SHIFT+K)

//Definitions
var work_id, kudos, banner, kudo_btn, cmnt_btn, cmnt_field, id;

work_id = window.location.pathname;
work_id = work_id.substring(work_id.lastIndexOf('/')+1);

banner = document.getElementById('kudos_message');

kudo_btn = document.getElementById('new_kudo');

cmnt_btn = document.getElementById('comment_submit_for_'+work_id);
cmnt_field = document.getElementById('comment_content_for_'+work_id);

// List of Assist Mode comment
var assist_msg = Array(
    "[This is me testing fastposting. Plus extra kudos :)]",
    "[Comment assist long version]",
    "[Comment assist short version]",
    "[You've already left kudos. Why not leave a comment instead? :)]"
);

//Fast Posting Mode
function fastsend() {
    cmnt_field.addEventListener("keyup", function(event) {
    if (event.keyCode === 13) {
        cmnt_btn.click();}
    });
}

//Assist mode basic functionality
function assist() {
    cmnt_field.value = assist_msg[assist_type];
    cmnt_btn.focus();
    window.scrollBy(0,200);
    cmnt_field.focus();
    if (fast_mode == true){
    fastsend();}
}

function makeitwork() {
console.log('If this message shows up before the "kudos.js" reply, make "lat" bigger');
if (banner.classList.contains("kudos_error") == true) {
    assist();}
}

function delay(){
    setTimeout(makeitwork,lat);
}

console.log("Assist Mode On");
kudo_btn.addEventListener("click", delay);