Greasy Fork

ao3 Comment Assist

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

目前为 2021-06-25 提交的版本。查看 最新版本

// ==UserScript==
// @name         ao3 Comment Assist
// @version      0.5
// @history      0.5 - Randomiser for Mode 2
// @history      0.2 - Rekudo compatibility
// @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==

//Check "Ao3 rekudos converter for additional acknowledgements
//https://greasyfork.org/en/scripts/427421-ao3-rekudos-converter

//SETUP//

var assist_type = 1;
    //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 = false;
    //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);

//Assist mode comments templates

var assist_msg, mode1, mode2, mode3, listofadditions;
mode1 = "[Hello from Rekudos Tools! You tried leaving a kudos when you've already left one. Comment assist mode has activated to remind you to leave a comment instead.] \n\n[If you know what kind of comment you want to leave, you can delete this message and write your own, but if you need help or this is the first time you're leaving a comment, here are some pointers:] \n\n[content] \n\n[Remember, that leaving comments is also a form of self-expression! No matter what kind of comment you decide to leave, thank you for deciding to share those feelings with the author!]";
mode2 = "[You've already left kudos here! Here's a random prompt to get you started on leaving a comment:] \n\n";
mode3 = "[You've already left kudos. Why not leave a comment instead? :)]";
listofadditions = Array(
    "[Random prompt 1]",
    "[Random prompt 2]",
    "[Random prompt 3]",
    "[Random prompt 4]"
);
var rerandom = Math.floor(Math.random() * listofadditions.length);
var mode2addition = listofadditions[rerandom];
mode2 = mode2+mode2addition+"\n\n[Remember: the more you leave comments, the better you become at it. Not every comment needs to be perfect :)]";

if (assist_type == 1) {
    assist_msg = mode1;
}
if (assist_type == 2) {
    assist_msg = mode2;
}
if (assist_type == 3) {
    assist_msg = mode3;
}

//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;
    cmnt_btn.focus();
    window.scrollBy(0,200);
    cmnt_field.focus();
    if (fast_mode == true){
    fastsend();}
}

function makeitwork() {
console.log("Assist Mode lat check");
if (banner.classList.contains("kudos_error") == true) {
    assist();}
}

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

(function(){
window.AssistMode = true;
console.log("Assist Mode On.");
})();

kudo_btn.addEventListener("click", delay);