Danbooru Tag Extractor

Extract tags from Danbooru image pages and copy them to the clipboard when a button is clicked.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

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.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name         Danbooru Tag Extractor
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Extract tags from Danbooru image pages and copy them to the clipboard when a button is clicked.
// @author       Shinnpuru
// @match        https://danbooru.donmai.us/posts/*
// @grant        GM_setClipboard
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    function extractTags() {
        // Select all tag links within the tag list section
        let tagElements = document.querySelectorAll('#tag-list a.search-tag');

        // Extract the text content of each tag
        let tags = [];
        tagElements.forEach(function(tagElement) {
            tags.push(tagElement.textContent.trim());
        });

        // Join the tags into a string separated by spaces
        return tags.join(',');
    }

    function createCopyButton() {
        // Create the button element
        let button = document.createElement('button');
        button.innerText = 'Copy Tags';
        button.style.position = 'fixed';
        button.style.bottom = '10px';
        button.style.right = '10px';
        button.style.padding = '10px';
        button.style.backgroundColor = '#008CBA';
        button.style.color = 'white';
        button.style.border = 'none';
        button.style.borderRadius = '5px';
        button.style.cursor = 'pointer';
        button.style.zIndex = '9999';

        // Add click event listener to the button
        button.addEventListener('click', function() {
            let tags = extractTags();
            GM_setClipboard(tags);
            alert('Tags copied to clipboard!');
        });

        // Append the button to the body
        document.body.appendChild(button);
    }

    // Run the script when the page is fully loaded
    window.addEventListener('load', createCopyButton);

})();