Danbooru Tags Copier

1-Click copies Danbooru, deep Danbooru tags. Useful as AI drawing prompts.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         Danbooru Tags Copier
// @namespace    ruocaled
// @version      0.11
// @description  1-Click copies Danbooru, deep Danbooru tags. Useful as AI drawing prompts.
// @author       You
// @match        https://danbooru.donmai.us/posts/*
// @match        http://dev.kanotype.net:8003/deepdanbooru/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=donmai.us
// @grant        none
// @license MIT
// ==/UserScript==
(function() {
  const copy = (hostname) => {
    if (hostname === "danbooru.donmai.us") {
      let tags = $(`.search-tag`).map((i, el) => $(el).text()).toArray().filter(tag => !tag.match(/hand|nail|finger|wrist/)).join(" ").toString();
      if (tags) {
        navigator.clipboard.writeText(tags);
      }
      return tags;
    } else {
      let tags = $(".col-md-auto tr a").map((i, el) => {
        return {
          tag: $(el).text().replace(/_/g, " "),
          score: parseFloat($(el).parent().next().text())
        };
      }).toArray().sort((a, b) => (b.score - a.score)).filter(el => el.score > 0.6 && !el.tag.match(/rating:/i)).map(el => el.tag).join(",");

      return tags;
    }

  };

  const addBtns = (hostname) => {
    if (hostname === "danbooru.donmai.us") {
      $("#post-options ul").append(`<li id="post-option-copy-tags">
          <a class="copy-tags-link"  href="#">Copy tags</a>
        </li>`);
      $("#post-option-copy-tags").click(() => {
        const tags = copy(hostname);
        $("#content").prepend(`<div class="notice notice-small post-notice">
        Tags have been copied to your clipboard. (<span style="color:var(--link-color)">${tags}</span>)
    </div>`);
      });
    } else {
$('img').after(`<div class="col-sm"></div><a class="copy-tags-link"  href="#">Copy tags</a></div>`);
      $(".copy-tags-link").click(() => {
        const tags = copy(hostname);
        $('.copy-tags-link').after(`<div>Sorted tags: <span style="color:blueviolet">${tags}</a> </div>`)
      });
    }

  };

  addBtns(location.hostname);

  // Your code here...
})();