jklm.fun embed

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

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

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

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

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

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

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.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

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