// ==UserScript== // @name ao3 rekudos converter // @version 2.0 // @history 2.0 - added confirmation check for rekudosing, did cleaned up // @history 1.55 - fixed stupid spelling errors // @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 https://greasyfork.org/users/36620 // @downloadURL none // ==/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 auto = false; //Set to "true" if you want to skip the confirmation automatically. 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+'
Sent '+id+' using Ao3 Rekudos Converter' //Comment-sending with button press rather than form submit function send() { cmnt_btn.click(); } //Extra click for confirmation var active = 'Rekudos?'; function rename() { 'use strict'; var kudo_text = document.querySelector('#kudo_submit'); kudo_text.value = active; change(); } //Change kudos button behaviour function change() { for (var i = 0; i < kudos.length; i++) { if (kudos[i].innerText == username) { cmnt_field.value = message; kudo_btn.addEventListener("click", send); break;} } } //Confirmation (this is ugly as hell don't even look at this) if (auto == true) { change();} else { for (var i = 0; i < kudos.length; i++) { if (kudos[i].innerText == username) { kudo_btn.addEventListener("click", rename); break;} } }