jklm.fun embed

Embed of any desired game/site with cycling toggle buttons for jklm.fun

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         jklm.fun embed
// @namespace    http://tampermonkey.net
// @version      1.0
// @description  Embed of any desired game/site with cycling toggle buttons for jklm.fun
// @author       HA_LOL_XD
// @match        *://*.jklm.fun/*
// @run-at       document-end
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    // 1. DUAL-WINDOW PROTECTION: Only run on the main JKLM page, not inside its game iframes
    if (window.self !== window.top) return;

    // 2. GAME LIST
    const games = [
        { name: '🐠 Orb Farm', url: 'https://orb.farm' },
        { name: '⏳ Sandspiel', url: 'https://sandspiel.club' }
    ];
    let currentGameIndex = 0;

    function init() {
        // Prevent duplicate buttons if they already exist
        if (document.getElementById('jklm-embed-controls')) return;

        // 3. UI Container (Top-Right)
        const container = document.createElement('div');
        container.id = 'jklm-embed-controls';
        container.style.cssText = 'position:fixed; top:10px; right:10px; z-index:10001; display:flex; gap:5px;';

        // 4. Cycle/Toggle Button
        const btn = document.createElement('button');
        btn.innerHTML = games[currentGameIndex].name;
        btn.style.cssText = 'padding:8px 12px; cursor:pointer; background:#222; color:#fff; border:1px solid #444; border-radius:5px; font-weight:bold; font-family:sans-serif; min-width:110px;';

        // 5. Reload Button
        const reloadBtn = document.createElement('button');
        reloadBtn.innerHTML = '🔄';
        reloadBtn.style.cssText = 'padding:8px 10px; cursor:pointer; background:#333; color:#fff; border:1px solid #444; border-radius:5px;';

        // 6. Close Button
        const closeBtn = document.createElement('button');
        closeBtn.innerHTML = '✖';
        closeBtn.style.cssText = 'padding:8px 12px; cursor:pointer; background:#800; color:#fff; border:1px solid #444; border-radius:5px; font-weight:bold;';

        // 7. Game Wrapper (Bottom-Left)
        const wrapper = document.createElement('div');
        wrapper.id = 'jklm-game-wrapper';
        wrapper.style.cssText = 'position:fixed; bottom:20px; left:20px; width:400px; height:500px; z-index:10000; display:none; background:#000; border:2px solid #555; border-radius:8px; overflow:hidden; box-shadow: 0 10px 25px rgba(0,0,0,0.8);';

        const iframe = document.createElement('iframe');
        iframe.src = games[currentGameIndex].url;
        iframe.style.cssText = 'width:800px; height:1000px; border:none; transform:scale(0.5); transform-origin:0 0;';

        // LOGIC: Toggle and Cycle
        btn.onclick = () => {
            if (wrapper.style.display === 'none') {
                wrapper.style.display = 'block';
            } else {
                currentGameIndex = (currentGameIndex + 1) % games.length;
                iframe.src = games[currentGameIndex].url;
                btn.innerHTML = games[currentGameIndex].name;
            }
            btn.style.background = '#007bff';
        };

        // LOGIC: Close
        closeBtn.onclick = () => {
            wrapper.style.display = 'none';
            btn.style.background = '#222';
        };

        // LOGIC: Reload current iframe
        reloadBtn.onclick = () => {
            iframe.src = games[currentGameIndex].url;
            reloadBtn.style.background = '#28a745';
            setTimeout(() => reloadBtn.style.background = '#333', 500);
        };

        // Append everything
        wrapper.appendChild(iframe);
        container.appendChild(btn);
        container.appendChild(reloadBtn);
        container.appendChild(closeBtn);
        document.body.appendChild(container);
        document.body.appendChild(wrapper);
    }

    // Run on load
    init();

    // Watch for JKLM page transitions to re-inject buttons if they get wiped
    const observer = new MutationObserver(() => {
        if (!document.getElementById('jklm-embed-controls')) {
            init();
        }
    });
    observer.observe(document.body, { childList: true, subtree: true });
})();