MediaWiki:Common.js

From The Walkscape Walkthrough
Revision as of 11:30, 30 April 2023 by KasiGen (talk | contribs) (Created page with "→‎Any JavaScript here will be loaded for all users on every page load.: →‎VARIABLES **********************************************************************************************************************: var currentPageUrl = window.location.href; var currentPageEditUrl = mw.util.getUrl( null, { action: 'edit' } ); var currentPageName = mw.util.getUrl( null, null ).replace('/wiki/', ''); var currentPageNamespaceID = mw.config.get('wgNamespaceNumber'); //variables...")
(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.
/* Any JavaScript here will be loaded for all users on every page load. */

/* VARIABLES ***********************************************************************************************************************/

var currentPageUrl = window.location.href;
var currentPageEditUrl = mw.util.getUrl( null, { action: 'edit' } );
var currentPageName = mw.util.getUrl( null, null ).replace('/wiki/', '');
var currentPageNamespaceID = mw.config.get('wgNamespaceNumber');

//variables needed after page load
var buttons, contents, allLinks;

//variables needed for the infobutton
var infobutton, infopanel;


/* *********************************************************************************************************************************/









/* sticky edit button */

// display the button only if #mw-content is present, if we are not in the edit mode, and if we're not in the Special: or Community: namespace
if (document.body.contains(document.getElementById("mw-content")) && !currentPageUrl.includes("action=") && currentPageNamespaceID != -1 && currentPageNamespaceID != 3004)  {
document.getElementById("mw-content").insertAdjacentHTML('afterbegin', '<a href="https://dragontamer.miraheze.org/' + currentPageEditUrl + '"><div id="custom-editbutton"><svg width="40" height="40" viewBox="-12 -10 50 50"><path d="M 20 2 L 26 8 L 8 26 L 2 26 L 2 20 Z M 16 6 L 22 12"></path></svg></div></a>');
}