User:DyPp-67/Common.js: Difference between revisions

From Test Wiki
Jump to navigation Jump to search
Content deleted Content added
Created page with "mw.loader.using('jquery', function () { // Check if jQuery is loaded if (typeof jQuery === "undefined") { console.error("jQuery is not loaded, the script will not work."); return; } // Function to create a button function createButton(text, color, bottom, onClick) { return $('<button>') .text(text) .css({ position: 'fixed', right: '10px', bott..."
Tags: Recreated Mobile edit Mobile web edit
 
(No difference)

Latest revision as of 10:43, 24 October 2025

mw.loader.using('jquery', function () { 
    // Check if jQuery is loaded 
    if (typeof jQuery === "undefined") { 
        console.error("jQuery is not loaded, the script will not work."); 
        return; 
    } 

    // Function to create a button 
    function createButton(text, color, bottom, onClick) { 
        return $('<button>') 
            .text(text) 
            .css({ 
                position: 'fixed', 
                right: '10px', 
                bottom: bottom + 'px', 
                padding: '8px 12px', 
                fontSize: '14px', 
                color: 'white', 
                backgroundColor: color, 
                border: '2px solid ' + color, 
                borderRadius: '6px', 
                zIndex: 9999, 
                cursor: 'pointer' 
            }) 
            .click(onClick) 
            .appendTo('body'); 
    } 

    createButton('↓ Bottom', '#e74c3c', 10, function () { 
        $('html, body').animate({ scrollTop: $(document).height() }, 'slow'); 
    }); 

    createButton('↑ Top', '#2ecc71', 60, function () { 
        $('html, body').animate({ scrollTop: 0 }, 'slow'); 
    }); 

    createButton('Recent changes', '#3498db', 110, function () { 
        window.location.href = '/wiki/Special:RecentChanges'; 
    }); 

    createButton('Desktop version', '#f39c12', 160, function () { 
        const url = new URL(window.location.href); 
        url.searchParams.set('useskin', 'vector'); 
        window.location.href = url.toString(); 
    }); 

    createButton('Mobile version', '#9b59b6', 210, function () { 
        const url = new URL(window.location.href); 
        url.searchParams.set('useskin', 'minerva'); 
        window.location.href = url.toString(); 
    }); 
});