MediaWiki:Monobook.js

From Guild Wars 2 Wiki
Jump to navigationJump to search

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)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
/*<nowiki>*/
console.log('[[MediaWiki:Monobook.js]] has loaded (revision 2022-12-01 18:28).');

if (document.readyState === 'loading') {
    // Loading hasn't finished yet (loading status)
    document.addEventListener('DOMContentLoaded', monobookJS);
} else {
    // 'DOMContentLoaded' has already fired (either at interactive or complete status)
    monobookJS();
}

function monobookJS() {

    /** Reposition footer to suit height of window **/
    function dynamicFooter() {
        console.log('Monobook: dynamicFooter function executed.');
        var footer = document.getElementById('footer');
        var content = document.getElementById('content');
        if (footer && content) {
            content.parentNode.insertBefore(footer, content.nextSibling);
            console.log('Monobook: Moved footer successfully.');
        }
    }
    dynamicFooter();
    
    /** Insert ArenaNet links into the top of the page **/
    function addMasthead() {
        console.log('Monobook: addMasthead function executed.');
        var a = document.createElement('div');
        a.id = 'upperBar';
        a.innerHTML = '<ul><li><a href="https://www.guildwars2.com/en" target="_blank">GuildWars2.com</a></li>'
                        +'<li><a href="https://en-forum.guildwars2.com/" target="_blank">Forums</a></li>'
                        +'<li><a href="https://help.guildwars2.com/hc/en-us" target="_blank">Support</a></li>'
                    +'</ul>';
        var column_one = document.getElementById('column-one');
        if (column_one) {
            column_one.appendChild(a);
            console.log('Monobook: Added masthead successfully.');
        }
    }
    addMasthead();

}

/*</nowiki>*/