Greasy Fork

Greasy Fork is available in English.

ao3 autocommenter

automatically comment on a fic when you've already left kudos

当前为 2021-06-02 提交的版本,查看 最新版本

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

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

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

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

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

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==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;}
}