Danbooru Tag 提取

Get General tags from Danbooru posts and copy them to clipboard

2024-01-08 기준 버전입니다. 최신 버전을 확인하세요.

이 스크립트를 설치하려면 Tampermonkey, Greasemonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

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

이 스크립트를 설치하려면 Tampermonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Userscripts와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 유저 스크립트 관리자 확장 프로그램이 필요합니다.

(이미 유저 스크립트 관리자가 설치되어 있습니다. 설치를 진행합니다!)

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

(이미 유저 스타일 관리자가 설치되어 있습니다. 설치를 진행합니다!)

// ==UserScript==
// @name         Danbooru Tag 提取
// @name:en      Danbooru Tag Crawler
// @namespace    https://danbooru.donmai.us/
// @version      1.0
// @description:zh-cn 一键提取当前图片的General tags并复制到剪贴板
// @description:en Get General tags from Danbooru posts and copy them to clipboard
// @author       LigHT
// @Copyright    2023 LigHT
// @license      MIT
// @match        https://danbooru.donmai.us/*
// @icon         https://www.google.com/s2/favicons?domain=donmai.us
// @grant        GM_setClipboard
// @description Get General tags from Danbooru posts and copy them to clipboard
// ==/UserScript==

(function() {
    'use strict';

    // Create a button in the bottom right corner
    var button = document.createElement("button");
    button.innerHTML = "get tag";
    button.style.position = "fixed";
    button.style.bottom = "1%";
    button.style.right = "1%";
    button.style.zIndex = "9999";
    button.style.opacity = "0.5";

    // Add a mouseover event listener to change opacity on hover
    button.addEventListener("mouseover", function() {
        button.style.opacity = "1";
    });

    // Add a mouseout event listener to change opacity back on mouseout
    button.addEventListener("mouseout", function() {
        button.style.opacity = "0.5";
    });

    document.body.appendChild(button);

    // Add a click event listener to the button
    button.addEventListener("click", function() {
        // Find the ul element with class "general-tag-list"
        var ul = document.querySelector("ul.general-tag-list");
        if (ul) {
            // Get all the li elements with attribute "data-tag-name"
            var lis = ul.querySelectorAll("li[data-tag-name]");
            // Create an array to store the tag names
            var tags = [];
            // Loop through the li elements and push the tag names to the array
            for (var i = 0; i < lis.length; i++) {
                var tag = lis[i].getAttribute("data-tag-name");
                tags.push(tag);
            }
            // Join the array with commas
            var result = tags.join(",");
            // Copy the result to clipboard
            GM_setClipboard(result);
            // Change the button text to "success"
            button.innerHTML = "success";
            // Set a timeout to change the button text back to "get tag" after 3 seconds
            setTimeout(function() {
                button.innerHTML = "get tag";
            }, 3000);
        }
    });
})();