Greasy Fork

Greasy Fork is available in English.

AO3: [Wrangling] Tag Comments Button + Iconify

Adds a comment button on wrangling bin pages + iconfies them to make it more compact

当前为 2017-06-13 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name        AO3: [Wrangling] Tag Comments Button + Iconify
// @namespace   adustyspectacle
// @description Adds a comment button on wrangling bin pages + 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.2
// @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 = '&#xf00d;';
    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 = '&#xf086;';
  tag_edit_btns[i].querySelector('a').innerHTML = '&#xf044;';
  tag_wrangle_btns[i].querySelector('a').innerHTML = '&#xf00b;';
  tag_works_btns[i].querySelector('a').innerHTML = '&#xf02d;';
  
  comment_link.setAttribute('href', comment_link_href);
  
  insertAfter(comment_btn, tag_edit_btns[i]);
}