User:Ricewind/common.js

From Melvor Idle
< User:Ricewind
Revision as of 18:01, 15 June 2024 by Ricewind (talk | contribs) (Created page with "$(document).ready(function() { // Create subpage link functionality function 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;...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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.
$(document).ready(function() {
    // Create subpage link functionality
    function 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;
    }

    // Add a button to create a subpage dynamically
    var createSubpageButton = '<input type="button" value="Create Subpage" onclick="createSubpage()">';
    $('#p-cactions').append(createSubpageButton);
});