Greasy Fork is available in English.
automatically comment on a fic when you've already left kudos
当前为
// ==UserScript==
// @name ao3 autocommenter
// @version 1.0
// @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
//KNOWN ISSUES: Doesn't always load correctly on fics with large amounts of kudos. Needs a better method for finding if you've kudos'ed fic, possibly by reacting to the "You've left kudos here" message itself.
//Comment Handler//
var message;
message = "This is an extra kudos, since I've already left one. :)"
//Remember to keep your message between the quotation marks.
//Message max length: 10000 characters
//****//
//Getting the username, work ID, site elements
var greeting, username, work_id, kudos, kudo_btn, cmnt_btn, cmnt_field;
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);
//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;}
}