Adds a comment button + iconfies them to make it more compact
当前为
// ==UserScript==
// @name AO3: [Wrangling] Quick Tag Comment Button + Iconify
// @namespace adustyspectacle
// @description Adds a comment button + iconfies them to make it more compact
// @include http://archiveofourown.org/tags/*/wrangle*
// @include https://archiveofourown.org/tags/*/wrangle*
// @include http://archiveofourown.org/tag_wranglings*
// @include https://archiveofourown.org/tag_wranglings*
// @version 1.1
// @grant none
// ==/UserScript==
var font_awesome_icons = document.createElement('script');
font_awesome_icons.setAttribute('src', 'https://use.fontawesome.com/ed555db3cc.js');
document.getElementsByTagName('head')[0].appendChild(font_awesome_icons);
var fa_icons_css = document.createElement('style');
fa_icons_css.setAttribute('type', 'text/css');
fa_icons_css.innerHTML = "tbody td ul.actions { font-family: FontAwesome, sans-serif; } tbody td .actions input[type='checkbox'] { margin: auto auto auto 0.5em; vertical-align: -0.35em; }";
document.getElementsByTagName('head')[0].appendChild(fa_icons_css);
function insertAfter(el, referenceNode) {
referenceNode.parentNode.insertBefore(el, referenceNode.nextSibling);
}
var btn_count = document.querySelector('table tbody ul.actions').children.length;
if (btn_count == 3) {
var tag_edit_btns = document.querySelectorAll('table tbody ul.actions li:nth-child(1)');
var tag_wrangle_btns = document.querySelectorAll('table tbody ul.actions li:nth-child(2)');
var tag_works_btns = document.querySelectorAll('table tbody ul.actions li:nth-child(3)');
} else if (btn_count == 4 ) {
var tag_remove_btns = document.querySelectorAll('table tbody ul.actions li:nth-child(1)');
var tag_edit_btns = document.querySelectorAll('table tbody ul.actions li:nth-child(2)');
var tag_wrangle_btns = document.querySelectorAll('table tbody ul.actions li:nth-child(3)');
var tag_works_btns = document.querySelectorAll('table tbody ul.actions li:nth-child(4)');
}
for (i = 0; i < tag_edit_btns.length; i++) {
if (btn_count == 4) {
var tag_remove_checkbox = tag_remove_btns[i].querySelector('input');
tag_remove_btns[i].querySelector('label').innerHTML = '';
tag_remove_btns[i].querySelector('label').appendChild(tag_remove_checkbox);
}
var comment_btn = tag_edit_btns[i].cloneNode(true);
var comment_link = comment_btn.querySelector('a');
var comment_link_href = comment_link.getAttribute('href').slice(0,-4) +'comments';
comment_link.innerHTML = '';
tag_edit_btns[i].querySelector('a').innerHTML = '';
tag_wrangle_btns[i].querySelector('a').innerHTML = '';
tag_works_btns[i].querySelector('a').innerHTML = '';
comment_link.setAttribute('href', comment_link_href);
insertAfter(comment_btn, tag_edit_btns[i]);
}