Superset Schema Toggle Button

Adds a toggle button to show/hide the schema pane in Superset's interface for better workspace management

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το 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        Superset Schema Toggle Button
// @include      *://*superset*/*
// @grant       none
// @version     1.0.1
// @author      AlecJi
// @description Adds a toggle button to show/hide the schema pane in Superset's interface for better workspace management
// @license MIT
// @namespace https://greasyfork.org/users/1442383
// ==/UserScript==

function createToggleButton() {
    // Check if button already exists to avoid duplicate creation
    if (document.getElementById('schema-toggle-btn')) {
        return;
    }

    const button = document.createElement('button');
    button.id = 'schema-toggle-btn';
    button.textContent = 'Hide Schema';
    button.style.cssText = `
        margin: 10px;
        padding: 8px 16px;
        border: 1px solid #d9d9d9;
        border-radius: 4px;
        background: #fff;
        cursor: pointer;
        font-size: 14px;
    `;

    // Wait for target container to appear
    function tryAddButton() {
        const targetDiv = document.querySelector('.css-pyvf21');
        if (targetDiv) {
            targetDiv.appendChild(button);

            // Add click event handler
            button.addEventListener('click', () => {
                const schemaPanes = document.getElementsByClassName('schemaPane');
                const isVisible = schemaPanes[0]?.style.display !== 'none';

                Array.from(schemaPanes).forEach(pane => {
                    pane.style.display = isVisible ? 'none' : 'block';
                });

                button.textContent = isVisible ? 'Show Schema' : 'Hide Schema';
            });
        } else {
            // If target container is not ready, retry after delay
            setTimeout(tryAddButton, 1000);
        }
    }

    tryAddButton();
}

// Execute when page is loaded
if (document.readyState === 'loading') {
    document.addEventListener('DOMContentLoaded', createToggleButton);
} else {
    createToggleButton();
}