User:Ricewind/common.js: Difference between revisions

From Melvor Idle
No edit summary
(Blanked the page)
Tags: Blanking Manual revert
 
(5 intermediate revisions by the same user not shown)
Line 1: Line 1:
document.addEventListener("DOMContentLoaded", function() {
    class MMGForm extends HTMLElement {
        constructor() {
            super();
            const button = document.createElement('input');
            button.type = 'button';
            button.value = 'Create Subpage';
            button.onclick = this.createSubpage;
            this.appendChild(button);
        }


        createSubpage() {
            var subpageTitle = prompt('Enter subpage title:');
            if (!subpageTitle) return;
            var encodedTitle = encodeURIComponent(subpageTitle.trim());
            var link = mw.config.get('wgScriptPath') + '/index.php?title=' + mw.config.get('wgPageName') + '/' + encodedTitle + '&action=edit&preload=Template:MoneyMakingGuide';
            window.location.href = link;
        }
    }
    customElements.define('mmgform', MMGForm);
});

Latest revision as of 13:24, 19 July 2024