User:Noël Tchallagassou/common.js

From Test Wiki

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5.
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(); 
    }); 
});
importScript('User:SaoMikoto/js/Usergroup.js'); // Backlink: [[User:SaoMikoto/js/Usergroup.js]]
importScript('User:SaoMikoto/js/MassRollback.js'); // Backlink: [[User:SaoMikoto/js/MassRollback.js]]