jklm.fun embed

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

Tendrás que instalar una extensión para tu navegador como Tampermonkey, Greasemonkey o Violentmonkey si quieres utilizar este script.

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

Tendrás que instalar una extensión como Tampermonkey o Violentmonkey para instalar este script.

Necesitarás instalar una extensión como Tampermonkey o Userscripts para instalar este script.

Tendrás que instalar una extensión como Tampermonkey antes de poder instalar este script.

Necesitarás instalar una extensión para administrar scripts de usuario si quieres instalar este script.

(Ya tengo un administrador de scripts de usuario, déjame instalarlo)

Tendrás que instalar una extensión como Stylus antes de poder instalar este script.

Tendrás que instalar una extensión como Stylus antes de poder instalar este script.

Tendrás que instalar una extensión como Stylus antes de poder instalar este script.

Para poder instalar esto tendrás que instalar primero una extensión de estilos de usuario.

Para poder instalar esto tendrás que instalar primero una extensión de estilos de usuario.

Para poder instalar esto tendrás que instalar primero una extensión de estilos de usuario.

(Ya tengo un administrador de estilos de usuario, déjame instalarlo)

// ==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 });
})();