Greasy Fork is available in English.
automatically comment on a fic when you've already left kudos
当前为
// ==UserScript==
// @name ao3 rekudos converter
// @version 1.5
// @history 1.5 - rename, add extra comment fields and ID functionality
// @history 1.0 - basic functionality
// @description automatically comment on a fic when you've already left kudos
// @include /https?://archiveofourown\.org/.*works/\d+/
// @grant none
// @namespace http://greasyfork.icu/users/36620
// ==/UserScript==
//ACNOWLEDGEMENT: most of the method is cribbed from "ao3 no rekudos" by scriptfairy
//I do not know enough JS to do shit like this on my own
//http://greasyfork.icu/en/scripts/406616-ao3-no-rekudos
//SETUP//
var comments = Array(
"Extra Kudos<3",
"This is an extra kudos, since I've already left one. :)",
"I just wanted to leave another kudos<3"
);
//Remember to keep your message between the quotation marks.
//Remember to separate comments with a comma!
//Message max length: 10000 characters
//****//
//Definitions
var greeting, username, work_id, kudos, kudo_btn, cmnt_btn, cmnt_field, id;
greeting = document.getElementById('greeting');
username = greeting.querySelector('a').href;
username = username.slice(username.lastIndexOf('/')+1);
work_id = window.location.pathname;
work_id = work_id.substring(work_id.lastIndexOf('/')+1);
kudos = document.getElementById('feedback');
kudos = kudos.querySelectorAll('.kudos a');
kudo_btn = document.getElementById('new_kudo');
cmnt_btn = document.getElementById('comment_submit_for_'+work_id);
cmnt_field = document.getElementById('comment_content_for_'+work_id);
//Message randomiser
var random = Math.floor(Math.random() * comments.length);
var message = comments[random];
// ID
var d = new Date();
id = d.toISOString();
id = id.substring(0,10);
message = message+'</br><sub>Sent '+id+' using Ao3 Rekudos Converter</sub>'+
//Comment-sending with button press rather than form submit
function send_cmnt() {
cmnt_btn.click();
}
//Change kudos button behaviour
for (var i = 0; i < kudos.length; i++) {
if (kudos[i].innerText == username) {
cmnt_field.value = message;
kudo_btn.addEventListener("click", send_cmnt);
break;
}
}