HotPot.ai show all styles

Добавляет всех стилей

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name            HotPot.ai show all styles
// @namespace       Wizzergod
// @version         1.0.7
// @description     Добавляет всех стилей
// @icon            https://www.google.com/s2/favicons?sz=64&domain=hotpot.ai
// @license         MIT
// @author          Wizzergod
// @match           *://hotpot.ai/art-generator*
// @match           *://hotpot.ai/remove-background*
// @match           *://hotpot.ai/anime-generator*
// @match           *://hotpot.ai/headshot/train*
// @match           *://hotpot.ai/logo-generator*
// @match           *://hotpot.ai/background-generator*
// @match           *://hotpot.ai/lunar-new-year-headshot*
// @match           *://hotpot.ai/ai-avatar*
// @match           *://hotpot.ai/ai-editor*
// @match           *://hotpot.ai/ai-stock-photo*
// @grant           GM_setValue
// @grant           GM_getValue
// @grant           GM_addStyle
// ==/UserScript==

(function() {
    'use strict';

    // Функция для извлечения названия @match из URL
    function extractMatchName(url) {
        const match = url.match(/hotpot\.ai\/([^\/]+)/);
        return match && match[1];
    }

    // Функция для обновления данных галереи
    function updateData(matchName) {
        const iframe = document.getElementById('hotpotCatalogOverlay');
        if (!iframe) {
            console.error('iframe not found');
            return;
        }

        const iframeContent = iframe.contentDocument || iframe.contentWindow.document;
        const galleryItems = iframeContent.querySelectorAll('.itemBox');
        const galleryData = [];

        galleryItems.forEach(item => {
            const itemId = item.getAttribute('data-itemid');
            const imgElement = item.querySelector('.imageBox img');

            if (imgElement && imgElement.hasAttribute('src')) {
                const imgSrc = imgElement.src;
                const itemName = item.querySelector('.name').textContent;

                if (itemId && itemId !== "null") {
                    galleryData.push({ itemId, imgSrc, itemName });
                }
            }
        });

        const key = `galleryData-${matchName}`;
        localStorage.setItem(key, JSON.stringify(galleryData));
        console.log('Gallery data saved for match:', matchName, galleryData);

        // Обновляем historyBox
        updateHistoryBox(matchName);
    }

    // Функция для обновления истории просмотров
    function updateHistoryBox(matchName) {
        const key = `galleryData-${matchName}`;
        const galleryData = JSON.parse(localStorage.getItem(key));
        const historyBox = document.querySelector('.historyBox');
        if (!historyBox) {
            console.error('historyBox not found');
            return;
        }
        historyBox.innerHTML = '';

        galleryData.forEach(data => {
            const thumbnailBox = document.createElement('div');
            thumbnailBox.className = 'thumbnailBox';
            thumbnailBox.setAttribute('styleid', data.itemId);
            thumbnailBox.setAttribute('stylelabel', data.itemName);

            const img = document.createElement('img');
            img.src = data.imgSrc;

            thumbnailBox.appendChild(img);
            historyBox.appendChild(thumbnailBox);
        });
    }

    // Функция для обновления данных после полной загрузки страницы
    function initialize() {
        const matchName = extractMatchName(window.location.href);
        if (matchName) {
            updateData(matchName);
        }
    }

    // Вызываем функцию для создания кнопки после полной загрузки страницы
    window.addEventListener('load', initialize);
})();