Greasy Fork is available in English.

Scratch GUI and Theme Changer

Add custom GUI and theme changer to Scratch

Voor het installeren van scripts heb je een extensie nodig, zoals Tampermonkey, Greasemonkey of Violentmonkey.

Voor het installeren van scripts heb je een extensie nodig, zoals {tampermonkey_link:Tampermonkey}.

Voor het installeren van scripts heb je een extensie nodig, zoals Tampermonkey of Violentmonkey.

Voor het installeren van scripts heb je een extensie nodig, zoals Tampermonkey of Userscripts.

Voor het installeren van scripts heb je een extensie nodig, zoals {tampermonkey_link:Tampermonkey}.

Voor het installeren van scripts heb je een gebruikersscriptbeheerder nodig.

(Ik heb al een user script manager, laat me het downloaden!)

Voor het installeren van gebruikersstijlen heb je een extensie nodig, zoals {stylus_link:Stylus}.

Voor het installeren van gebruikersstijlen heb je een extensie nodig, zoals {stylus_link:Stylus}.

Voor het installeren van gebruikersstijlen heb je een extensie nodig, zoals {stylus_link:Stylus}.

Voor het installeren van gebruikersstijlen heb je een gebruikersstijlbeheerder nodig.

Voor het installeren van gebruikersstijlen heb je een gebruikersstijlbeheerder nodig.

Voor het installeren van gebruikersstijlen heb je een gebruikersstijlbeheerder nodig.

(Ik heb al een beheerder - laat me doorgaan met de installatie!)

// ==UserScript==
// @name         Scratch GUI and Theme Changer
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Add custom GUI and theme changer to Scratch
// @match        https://scratch.mit.edu/*
// @grant        GM_addStyle
// @run-at       document-end
// ==/UserScript==

(function() {
    'use strict';

    // Function to create a page
    function createPage(id, title, content) {
        const page = document.createElement('div');
        page.id = id;
        page.style.display = 'none';
        page.style.position = 'fixed';
        page.style.top = '10px';
        page.style.left = '10px';
        page.style.backgroundColor = '#ffffff';
        page.style.border = '1px solid #ddd';
        page.style.padding = '10px';
        page.style.zIndex = 1000;
        page.style.borderRadius = '5px';
        page.style.boxShadow = '0 0 10px rgba(0, 0, 0, 0.3)';
        page.style.fontFamily = 'Arial, sans-serif';
        page.innerHTML = `<h2>${title}</h2>${content}`;
        document.body.appendChild(page);
    }

    // Function to create the main GUI
    function createMainGUI() {
        const mainGUI = document.createElement('div');
        mainGUI.id = 'main-gui';
        mainGUI.style.position = 'fixed';
        mainGUI.style.top = '10px';
        mainGUI.style.right = '10px';
        mainGUI.style.backgroundColor = '#ffffff';
        mainGUI.style.border = '1px solid #ddd';
        mainGUI.style.padding = '10px';
        mainGUI.style.zIndex = 1000;
        mainGUI.style.borderRadius = '5px';
        mainGUI.style.boxShadow = '0 0 10px rgba(0, 0, 0, 0.3)';
        mainGUI.style.fontFamily = 'Arial, sans-serif';
        document.body.appendChild(mainGUI);

        const pages = ['block-editor', 'block-color-changer', 'custom-block-maker', 'theme-changer'];

        pages.forEach(pageId => {
            const button = document.createElement('button');
            button.innerText = pageId.replace(/-/g, ' ').toUpperCase();
            button.style.margin = '5px';
            button.style.padding = '5px 10px';
            button.style.border = 'none';
            button.style.borderRadius = '3px';
            button.style.cursor = 'pointer';
            button.style.backgroundColor = '#007bff';
            button.style.color = '#fff';
            button.onclick = function() {
                pages.forEach(id => {
                    document.getElementById(id).style.display = (id === pageId) ? 'block' : 'none';
                });
            };
            mainGUI.appendChild(button);
        });

        const closeButton = document.createElement('button');
        closeButton.innerText = 'Close GUI';
        closeButton.style.margin = '5px';
        closeButton.style.padding = '5px 10px';
        closeButton.style.border = 'none';
        closeButton.style.borderRadius = '3px';
        closeButton.style.cursor = 'pointer';
        closeButton.style.backgroundColor = '#dc3545';
        closeButton.style.color = '#fff';
        closeButton.onclick = function() {
            mainGUI.style.display = (mainGUI.style.display === 'none') ? 'block' : 'none';
        };
        mainGUI.appendChild(closeButton);
    }

    // Function to create the Block Editor page
    function createBlockEditorPage() {
        createPage('block-editor', 'Block Editor', `
            <label for="block-select">Select Block:</label>
            <select id="block-select">
                <!-- Populate with block options -->
            </select>
            <br/><br/>
            <label for="block-color">Block Color:</label>
            <input type="color" id="block-color" />
            <br/><br/>
            <label for="block-inside-color">Inside Color:</label>
            <input type="color" id="block-inside-color" />
            <br/><br/>
            <button onclick="applyBlockEdits()">Apply Changes</button>
        `);

        window.applyBlockEdits = function() {
            const blockColor = document.getElementById('block-color').value;
            const blockInsideColor = document.getElementById('block-inside-color').value;
            console.log('Applying block edits:', blockColor, blockInsideColor);
            // Implement logic to apply block color changes
        };
    }

    // Function to create the Block Color Changer page
    function createBlockColorChangerPage() {
        createPage('block-color-changer', 'Block Color Changer', `
            <label for="block-select-color">Select Block:</label>
            <select id="block-select-color">
                <!-- Populate with block options -->
            </select>
            <br/><br/>
            <label for="block-new-color">New Block Color:</label>
            <input type="color" id="block-new-color" />
            <br/><br/>
            <button onclick="changeBlockColor()">Change Color</button>
        `);

        window.changeBlockColor = function() {
            const block = document.getElementById('block-select-color').value;
            const newColor = document.getElementById('block-new-color').value;
            console.log('Changing block color to:', newColor);
            // Implement logic to change the color of the selected block
        };
    }

    // Function to create the Custom Block Maker page
    function createCustomBlockMakerPage() {
        createPage('custom-block-maker', 'Custom Block Maker', `
            <label for="block-name">Block Name:</label>
            <input type="text" id="block-name" />
            <br/><br/>
            <label for="block-color-new">Block Color:</label>
            <input type="color" id="block-color-new" />
            <br/><br/>
            <label for="block-inside-color-new">Inside Color:</label>
            <input type="color" id="block-inside-color-new" />
            <br/><br/>
            <button onclick="createCustomBlock()">Create Block</button>
        `);

        window.createCustomBlock = function() {
            const blockName = document.getElementById('block-name').value;
            const blockColor = document.getElementById('block-color-new').value;
            const blockInsideColor = document.getElementById('block-inside-color-new').value;
            console.log('Creating custom block:', blockName, blockColor, blockInsideColor);
            // Implement logic to create a custom block with the given properties
        };
    }

    // Function to create the Theme Changer page
    function createThemeChangerPage() {
        createPage('theme-changer', 'Theme Changer', `
            <label for="theme-select">Select Theme:</label>
            <select id="theme-select">
                <option value="cupcake">Cupcake</option>
                <option value="candy">Candy</option>
                <option value="dark">Dark</option>
                <option value="marshmallow">Marshmallow</option>
                <option value="bloody">Bloody</option>
                <option value="image">Image</option>
            </select>
            <br/><br/>
            <label for="theme-image-url" id="image-url-label" style="display: none;">Image URL:</label>
            <input type="text" id="theme-image-url" style="display: none;" />
            <br/><br/>
            <button onclick="applyTheme()">Apply Theme</button>
        `);

        window.applyTheme = function() {
            const theme = document.getElementById('theme-select').value;
            const imageUrl = document.getElementById('theme-image-url').value;
            
            const themes = {
                'cupcake': `
                    body { background-color: #fbe8e8; color: #6a1b29; }
                    .stage { background: #fcdada; }
                    .backdrop { background: #f6a7b1; }
                `,
                'candy': `
                    body { background-color: #f7e7e0; color: #ff4f5a; }
                    .stage { background: #e5c7c3; }
                    .backdrop { background: #e6a4a4; }
                `,
                'dark': `
                    body { background-color: #1e1e1e; color: #dcdcdc; }
                    .stage { background: #333333; }
                    .backdrop { background: #444444; }
                `,
                'marshmallow': `
                    body { background-color: #f9f9f9; color: #7e7e7e; }
                    .stage { background: #fefefe; }
                    .backdrop { background: #e0e0e0; }
                `,
                'bloody': `
                    body { background-color: #4d0a0a; color: #f5f5f5; }
                    .stage { background: #6a0b0b; }
                    .backdrop { background: #9e0f0f; }
                `,
                'image': `
                    body { background-image: url('${imageUrl}'); color: #ffffff; }
                    .stage { background: rgba(0, 0, 0, 0.5); }
                    .backdrop { background: rgba(0, 0, 0, 0.5); }
                `
            };

            if (theme === 'image') {
                document.getElementById('image-url-label').style.display = 'block';
                document.getElementById('theme-image-url').style.display = 'block';
            } else {
                document.getElementById('image-url-label').style.display = 'none';
                document.getElementById('theme-image-url').style.display = 'none';
                applyThemeStyles(themes[theme]);
            }
        };

        function applyThemeStyles(css) {
            let existingStyle = document.getElementById('theme-style');
            if (existingStyle) {
                existingStyle.remove();
            }
            const style = document.createElement('style');
            style.id = 'theme-style';
            style.innerHTML = css;
            document.head.appendChild(style);
        }
    }

    // Initialize GUI and pages
    createMainGUI();
    createBlockEditorPage();
    createBlockColorChangerPage();
    createCustomBlockMakerPage();
    createThemeChangerPage();
})();