Difference between revisions of "MediaWiki:Common.js"
From Dungeon Defenders 2 Wiki
(Test :)) |
|||
Line 16: | Line 16: | ||
Array.from(document.getElementsByClassName('pass-xp')).forEach(function (element) { | Array.from(document.getElementsByClassName('pass-xp')).forEach(function (element) { | ||
element.innerHTML = element.innerHTML.replace(/xp?(\d.+)|(\d.+)xp?/gi, '<a class="image"><img alt="Defender Pass XP Icon.png" src="/images/2/23/Defender_Pass_XP_Icon.png" width="18"></a> $1$2') | element.innerHTML = element.innerHTML.replace(/xp?(\d.+)|(\d.+)xp?/gi, '<a class="image"><img alt="Defender Pass XP Icon.png" src="/images/2/23/Defender_Pass_XP_Icon.png" width="18"></a> $1$2') | ||
+ | }) | ||
+ | |||
+ | /* Replaces the rarity keywords like "mythical" or "legendary" to have their icon with the rarity */ | ||
+ | Array.from(document.getElementsByClassName('rarity')).forEach(function (element) { | ||
+ | element.innerHTML = element.innerHTML.replace(/worn/gi, '<a class="image" style="color: #808080;"><img alt="Worn Icon.png" src="/images/3/34/Worn_Icon.png" width="18"></a>') | ||
+ | element.innerHTML = element.innerHTML.replace(/sturdy/gi, '<a class="image" style="color: #808080;"><img alt="Sturdy Icon.png" src="/images/c/cf/Sturdy_Icon.png" width="18"></a>') | ||
+ | element.innerHTML = element.innerHTML.replace(/powerful/gi, '<a class="image" style="color: #808080;"><img alt="Powerful Icon.png" src="/images/2/29/Powerful_Icon.png" width="18"></a>') | ||
+ | element.innerHTML = element.innerHTML.replace(/epic/gi, '<a class="image" style="color: #808080;"><img alt="Epic Icon.png" src="/images/f/fc/Epic_Icon.png" width="18"></a>') | ||
}) | }) |
Revision as of 18:50, 7 November 2023
/* 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?(\d.+)|(\d.+)gems?/gi, '<a href="/wiki/Gems" 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(\d.+)|(\d.+)gold/gi, '<a href="/wiki/Gold" 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?(\d.+)|(\d.+)defender medals?/gi, '<a href="/wiki/Defender_Medals" class="image"><img alt="Defender Medal Icon.png" src="/images/a/a7/Defender_Medal_Icon.png" width="18"></a> $1$2') }) /* Replaces the XP keyword with the Ascension XP icon in elements which include Ascension XP numbers */ Array.from(document.getElementsByClassName('ascension-xp')).forEach(function (element) { element.innerHTML = element.innerHTML.replace(/xp?(\d.+)|(\d.+)xp?/gi, '<a href="/wiki/Experience" class="image"><img alt="Ascension XP Icon.png" src="/images/c/cf/Ascension_XP_Icon.png" width="18"></a> $1$2') }) /* Replaces the XP keyword with the Defender Pass XP icon in elements which include Defender Pass XP numbers */ Array.from(document.getElementsByClassName('pass-xp')).forEach(function (element) { element.innerHTML = element.innerHTML.replace(/xp?(\d.+)|(\d.+)xp?/gi, '<a class="image"><img alt="Defender Pass XP Icon.png" src="/images/2/23/Defender_Pass_XP_Icon.png" width="18"></a> $1$2') }) /* Replaces the rarity keywords like "mythical" or "legendary" to have their icon with the rarity */ Array.from(document.getElementsByClassName('rarity')).forEach(function (element) { element.innerHTML = element.innerHTML.replace(/worn/gi, '<a class="image" style="color: #808080;"><img alt="Worn Icon.png" src="/images/3/34/Worn_Icon.png" width="18"></a>') element.innerHTML = element.innerHTML.replace(/sturdy/gi, '<a class="image" style="color: #808080;"><img alt="Sturdy Icon.png" src="/images/c/cf/Sturdy_Icon.png" width="18"></a>') element.innerHTML = element.innerHTML.replace(/powerful/gi, '<a class="image" style="color: #808080;"><img alt="Powerful Icon.png" src="/images/2/29/Powerful_Icon.png" width="18"></a>') element.innerHTML = element.innerHTML.replace(/epic/gi, '<a class="image" style="color: #808080;"><img alt="Epic Icon.png" src="/images/f/fc/Epic_Icon.png" width="18"></a>') })