Difference between revisions of "MediaWiki:Common.js"

From Dungeon Defenders 2 Wiki
Jump to: navigation, search
(Created page with "Any JavaScript here will be loaded for all users on every page load.: Replaces the word "gems" with the gem icon in texts where gem costs are mentioned: [...documen...")
 
Line 2: Line 2:
  
 
/* Replaces the word "gems" with the gem icon in texts where gem costs are mentioned */
 
/* Replaces the word "gems" with the gem icon in texts where gem costs are mentioned */
[...document.getElementsByClassName('gem-cost-included')].forEach(element => {
+
Array.from(document.getElementsByClassName('gem-cost-included')).forEach(element => {
     element.textContent = element.textContent.replace(/gems\s*?(\d+)|(\d+)\s*?gems/, '[[File:Gem Icon.png|18px]] $1$2')
+
     element.textContent = element.textContent.replace(/gems\s*?(\d+)|(\d+)\s*?gems/g, '[[File:Gem Icon.png|18px]] $1$2')
 
})
 
})

Revision as of 22:26, 14 February 2023

/* Any JavaScript here will be loaded for all users on every page load. */

/* Replaces the word "gems" with the gem icon in texts where gem costs are mentioned */
Array.from(document.getElementsByClassName('gem-cost-included')).forEach(element => {
    element.textContent = element.textContent.replace(/gems\s*?(\d+)|(\d+)\s*?gems/g, '[[File:Gem Icon.png|18px]] $1$2')
})