Random Prompt from Related Tags.

Press Ctrl+Y to create a random prompt from the results of Danbooru's RelatedTags and copy it to the clipboard. If you press Alt, it will be 20, if you press Shift, it will be 30, and if you press both Alt and Shift, it will be 50.

13.01.2024 itibariyledir. En son verisyonu görün.

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

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

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

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.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==UserScript==
// @name         Random Prompt from Related Tags.
// @namespace    https://www6.notion.site/dc99953d5f04405c893fba95dace0722
// @version      1
// @description  Press Ctrl+Y to create a random prompt from the results of Danbooru's RelatedTags and copy it to the clipboard. If you press Alt, it will be 20, if you press Shift, it will be 30, and if you press both Alt and Shift, it will be 50.
// @author       SenY
// @match        https://danbooru.donmai.us/related_tag*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=donmai.us
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';
    const generateTags = (tagsLimit) => {
        let tags = document.getElementById("search_query").value.split(" ").map(x => x.trim().replace(/_/g, " "));
        let order = document.getElementById("search_order")
        if(order && order.value){
            order = order.value.toLowerCase();
            while (tags.length < tagsLimit){
                document.querySelectorAll('[href^="/posts?tags="]').forEach(a => {
                    let tr = a.closest("tr");
                    let tag = a.textContent.trim().replace(/_/g, " ");
                    let num = tr.querySelector("."+order+"-column span").textContent.replace("%", "") - 0;
                    let randomNum = Math.floor(Math.random() * 101);
                    if (num > randomNum && tags.length < tagsLimit && !tags.includes(tag) ) {
                        tags.push(tag);
                    }
                })
            }
            console.log(tags.join(", "));
            navigator.clipboard.writeText(tags.join(", "));
        }else{
            alert("Please select any value on Order property.");
        }
    }
    document.addEventListener("keyup", (e) => {
        if (e.ctrlKey && e.code === 'KeyY') {
            if (!e.altKey && !e.shiftKey) {
                generateTags(10);
            } else if (e.altKey && !e.shiftKey) {
                generateTags(20);
            } else if (!e.altKey && e.shiftKey) {
                generateTags(30);
            } else if (e.altKey && e.shiftKey) {
                generateTags(50);
            }
        }
    });
})();