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. */
/**
* @param {HTMLImageElement} img
*/
function fixBrokenImg(img) {
var pattern = /\/w\/thumb\.php\?f=([\w%\-]+)\.svg/gi;
var result = pattern.exec(img.src);
if (result) {
img.src = "/wiki/Special:FilePath/" + result[1] + ".svg";
}
}
function findBrokenImages() {
$('figure[typeof="mw:File/Thumb"]>a.mw-file-description>img').each(function (_index, elm) {
if (elm instanceof HTMLImageElement && (!elm.complete || elm.naturalWidth === 0)) {
fixBrokenImg(elm);
}
});
$("div.fullImageLink a img").each(function (_index, elm) {
if (elm instanceof HTMLImageElement && (!elm.complete || elm.naturalWidth === 0)) {
fixBrokenImg(elm);
}
});
}
function renderDiscordWidgets() {
$(".discord-widget-wrapper").each(function (_index, elm) {
var serverId = $(elm).attr("data-discord-id");
if (!serverId) {
return;
}
var widgetHeight = $(elm).attr("data-widget-height") || "570";
var widgetWidth = $(elm).attr("data-widget-width") || "270";
var widgetUrl = "https://discord.com/widget?id=" + serverId + "&theme=dark";
$(elm).html(
'<iframe src="' + widgetUrl + '" ' +
'width="' + widgetWidth + '" height= "' + widgetHeight + '" ' +
'allowtransparency="true" frameborder="0" ' +
'sandbox="allow-popups allow-popups-to-escape-sandbox allow-same-origin allow-scripts"' +
'></iframe>'
);
});
}
var windowLoaded = false;
window.addEventListener("load", function () {
if (!windowLoaded) {
windowLoaded = true;
findBrokenImages();
renderDiscordWidgets();
}
});
setTimeout(function () {
if (!windowLoaded) {
window.dispatchEvent(new Event("load"))
}
}, 1000);