CCCPaste
// == RLgg Online Script Loader with UI ==
// Works on RLgg JavaScript environment
// Built for remote Pastebin raw scripts

(function() {

    // 🧩 Create Layout
    let layout = {
        view: "linear",
        orientation: "vertical",
        padding: 12,
        gravity: "center",
        children: [
            {
                view: "text",
                text: "🌐 RLgg Online Loader",
                textSize: 20,
                textColor: "#00FFAA",
                gravity: "center"
            },
            {
                id: "linkInput",
                view: "edit",
                hint: "Paste your Pastebin raw link here",
                singleLine: true,
                textSize: 14,
                textColor: "#FFFFFF",
                hintTextColor: "#888888",
                padding: 8,
                background: "#222222"
            },
            {
                id: "statusText",
                view: "text",
                text: "Status: Waiting for input...",
                textColor: "#AAAAAA",
                textSize: 13,
                margin: [0, 10, 0, 10]
            },
            {
                view: "button",
                text: "🚀 Load Script",
                textColor: "#FFFFFF",
                background: "#00AAFF",
                cornerRadius: 10,
                onClick: function() {
                    let link = layoutData.linkInput.text;
                    if (!link || !link.startsWith("http")) {
                        layoutData.statusText.text = "⚠️ Invalid link.";
                        return;
                    }
                    loadScript(link);
                }
            }
        ]
    };

    // 🧠 Keep layout reference
    let layoutData = rlgg.showLayout(layout);

    // ⚙️ Fetch and execute function
    async function loadScript(link) {
        layoutData.statusText.text = "⏳ Fetching script...";
        try {
            const res = await fetch(link);
            if (!res.ok) throw new Error("HTTP " + res.status);
            const code = await res.text();

            if (!code.trim()) {
                layoutData.statusText.text = "❌ Empty or invalid script.";
                return;
            }

            layoutData.statusText.text = "✅ Script downloaded. Executing...";
            try {
                eval(code);
                layoutData.statusText.text = "🚀 Script executed successfully!";
            } catch (e) {
                layoutData.statusText.text = "❌ Execution Error: " + e.message;
            }
        } catch (err) {
            layoutData.statusText.text = "⚠️ Fetch failed: " + err.message;
        }
    }

})();