From 943da49c045c8849dc5179a4a5e2a70734f75b95 Mon Sep 17 00:00:00 2001 From: Sainan Date: Thu, 28 Nov 2024 06:05:50 +0100 Subject: [PATCH] Use content.warframe.com for higher-quality images when possible --- common.js | 21 +++++++++++++++++++++ glyphs.php | 6 ++++-- index.php | 5 ++++- 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/common.js b/common.js index a09f3fd..af529b9 100644 --- a/common.js +++ b/common.js @@ -40,6 +40,27 @@ if (localStorage.getItem("lang")) setLanguageIndicator(localStorage.getItem("lang")); } +// Images + +function setImageSource(img, icon) +{ + if (icon in ExportImages) + { + img.src = "https://content.warframe.com/PublicExport" + icon + "!" + ExportImages[icon].contentHash; + + // Fix for /Lotus/Interface/Icons/Player/ContentCreators/DeathMa666ot.png + img.onerror = function() + { + console.warn("Failed to load icon from content.warframe.com:", icon); + img.src = "https://browse.wf" + icon; + }; + } + else + { + img.src = "https://browse.wf" + icon; + } +} + // Text icons function resolveTextIcons(text) diff --git a/glyphs.php b/glyphs.php index 44b6ff0..26477b0 100644 --- a/glyphs.php +++ b/glyphs.php @@ -63,11 +63,13 @@ Promise.all([ getDictPromise(), fetch("https://browse.wf/warframe-public-export-plus/ExportFlavour.json").then(res => res.json()), + fetch("https://browse.wf/warframe-public-export-plus/ExportImages.json").then(res => res.json()), fetch("supplemental-data/glyphs.json").then(res => res.json()) - ]).then(([ dict, ExportFlavour, supplementalGlyphData ]) => + ]).then(([ dict, ExportFlavour, ExportImages, supplementalGlyphData ]) => { window.dict = dict; window.ExportFlavour = ExportFlavour; + window.ExportImages = ExportImages; window.supplementalGlyphData = supplementalGlyphData; updateList(); @@ -113,7 +115,7 @@ function updateList() { const img = document.createElement("img"); img.alt = img.title = (dict[item.name] ?? b[1].name); - img.src = "https://browse.wf" + item.icon; + setImageSource(img, item.icon); glyph.appendChild(img); } document.getElementById("list").appendChild(glyph); diff --git a/index.php b/index.php index 9b30e9c..d03495b 100644 --- a/index.php +++ b/index.php @@ -51,6 +51,7 @@ fetch("https://browse.wf/warframe-public-export-plus/ExportRegions.json").then(res => res.json()), fetch("https://browse.wf/warframe-public-export-plus/ExportEnemies.json").then(res => res.json()), fetch("https://browse.wf/warframe-public-export-plus/ExportRecipes.json").then(res => res.json()), + fetch("https://browse.wf/warframe-public-export-plus/ExportImages.json").then(res => res.json()), fetch("https://browse.wf/warframe-public-export-plus/ExportTextIcons.json").then(res => res.json()), fetch("supplemental-data/glyphs.json").then(res => res.json()) ]).then(([ @@ -68,6 +69,7 @@ ExportRegions, ExportEnemies, ExportRecipes, + ExportImages, ExportTextIcons, supplementalGlyphData ]) => @@ -86,6 +88,7 @@ window.ExportRewards = ExportRewards; window.ExportRegions = ExportRegions; window.ExportEnemies = ExportEnemies; + window.ExportImages = ExportImages; window.ExportTextIcons = ExportTextIcons; window.supplementalGlyphData = supplementalGlyphData; @@ -237,7 +240,7 @@ function doQuery(query) { const img = document.createElement("img"); img.className = "img-fluid rounded-start"; - img.src = "https://browse.wf" + result.value.icon; + setImageSource(img, result.value.icon); col.appendChild(img); } row.appendChild(col);