NomenChat/Box3

NomenChat/Box3浮窗

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

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

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

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.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name         NomenChat/Box3
// @namespace    https://github.com/helloyork
// @version      0.1
// @description  NomenChat/Box3浮窗
// @author       Nomen
// @match        https://box3.codemao.cn/e/*
// @icon         https://github.com/helloyork/lib/blob/main/Nomen.png?raw=true
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    let main = (async()=>{
        if(!window || !document)return;
        function loadSource(src){
            return new Promise(r=>{
                fetch(src).then(v=>v.text()).then(v=>r(v));
            })
        }
        async function initButton(){
            let b = document.createElement("div");
            b.innerHTML=await loadSource("https://raw.githubusercontent.com/helloyork/lib/main/Box3/nomenchat.html");
            document.body.appendChild(b);
        };
        await initButton();
        var button = document.getElementById('circle-button');
        var iframeContainer = document.getElementById('iframe-container');
        var robotIcon = document.getElementById('robot-icon');
        var closeIcon = document.getElementById('close-icon');

        button.addEventListener('click', function () {
            if (iframeContainer.classList.contains('show')) {
                iframeContainer.classList.remove('show');
                closeIcon.style.display = 'none';
                robotIcon.style.display = 'block';
                iframeContainer.addEventListener('transitionend', function() {
                    if (!iframeContainer.classList.contains('show')) {
                        iframeContainer.style.display = "none";
                    }
                }, {once: true});
            } else {
                iframeContainer.style.display = "block";
                setTimeout(function(){
                    iframeContainer.classList.add('show');
                },0);
                closeIcon.style.display = 'block';
                robotIcon.style.display = 'none';
            }
        });
    });
    setTimeout(main,2000)
})();