Changes

MediaWiki:Common.js

14 bytes added, 01:09, 16 November 2023
Making currency keyphrases case-insensitive
/* Replaces currency keywords (Gold, Gems, Defender Medals) with their icon in elements which include currency costs */
const currencyIcons = {
"Gemgem": '<a href="/wiki/Gems" class="image"><img alt="Gem Icon.png" src="/images/8/8d/Gem_Icon.png" width="18"></a>', "Goldgold": '<a href="/wiki/Gold" class="image"><img alt="Gold Icon.png" src="/images/2/26/Gold_Icon.png" width="18"></a>', "Defender Medaldefender medal": '<a href="/wiki/Defender_Medals" class="image"><img alt="Defender Medal Icon.png" src="/images/a/a7/Defender_Medal_Icon.png" width="18"></a>'
}
const phrases = element.innerHTML.match(currencyRegex)
phrases.forEach(function (phrase){
const currency = phrase.match(/Gem|Gold|Defender Medal/i).toString().toLowerCase()
const replacement = phrase.replace(currencyRegex, currencyIcons[currency] + " $2$3")
element.innerHTML = element.innerHTML.replace(phrase, replacement)
WikiDefender, bureaucrat, administrator
618
edits