MediaWiki:Common.js
From AnarchyMU Wiki
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)
- Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5.
/* Any JavaScript here will be loaded for all users on every page load. */
// Ensures class card images use the intended foreground image if data-src is present.
(function () {
function applyDataSrc() {
var images = document.querySelectorAll('.mw-card-image img[data-src]');
for (var i = 0; i < images.length; i++) {
var img = images[i];
var dataSrc = img.getAttribute('data-src');
if (dataSrc && img.getAttribute('src') !== dataSrc) {
img.setAttribute('src', dataSrc);
}
}
}
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', applyDataSrc);
} else {
applyDataSrc();
}
})();