MediaWiki:Common.js

From Dungeon Defenders 2 Wiki
Revision as of 03:01, 13 April 2023 by Paloverde zfogshooterz (talk | contribs) (retest)

Jump to: navigation, search

Note: After saving, 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: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Go to Menu → Settings (Opera → Preferences on a Mac) and then to Privacy & security → Clear browsing data → Cached images and files.
/* Any JavaScript here will be loaded for all users on every page load. */

/* Replaces currency keywords (gold, gems, defender medals) with their icon in texts which include currency costs */
Array.from(document.getElementsByClassName('currency-included')).forEach(function (element) {
    element.innerHTML = element.innerHTML.replace(/gems?\s*?([\d,]+)|([\d,]+)\s*?gems?/gi, '<a href="/wiki/File:Gem_Icon.png" class="image"><img alt="Gem Icon.png" src="/images/8/8d/Gem_Icon.png" width="18"></a> $1$2')
    element.innerHTML = element.innerHTML.replace(/gold\s*?([\d,]+)|([\d,]+)\s*?gold/gi, '<a href="/wiki/File:Gold_Icon.png" class="image"><img alt="Gold Icon.png" src="/images/2/26/Gold_Icon.png" width="18"></a> $1$2')
    element.innerHTML = element.innerHTML.replace(/defender medals?\s*?([\d,]+)|([\d,]+)\s*?defender medals?/gi, '<a href="/wiki/File:Defender_Medal_Icon.png" class="image"><img alt="Defender Medal Icon.png" src="/images/a/a7/Defender_Medal_Icon.png" width="18"></a> $1$2')
})

importArticles({
    type: 'script',
    articles: [
        'u:dev:MediaWiki:Tooltips.js',
    ]
});