diff --git a/internal/sha-inverse-challenge.html b/internal/sha-inverse-challenge.html index 965cbf9..78e31c6 100644 --- a/internal/sha-inverse-challenge.html +++ b/internal/sha-inverse-challenge.html @@ -169,6 +169,27 @@ return selectedMessage; } + function getFavicon(imgElement) { + // Build the base URL in a backward-compatible way + var origin = window.location.protocol + "//" + window.location.host; + var faviconUrl = origin + '/favicon.ico'; + var fallbackSvg = imgElement.src; + var testImage = new Image(); + + testImage.src = faviconUrl + + // Set favicon if it loads successfully + testImage.addEventListener('load', function() { + imgElement.src = faviconUrl; + }); + + // Fallback to SVG if favicon fails to load + testImage.addEventListener('error', function() { + console.log('Favicon not found, falling back to SVG'); + imgElement.src = fallbackSvg; + }); + } + function setDomainName() { document.getElementsByClassName("website-title")[0].textContent = window.location.hostname; @@ -182,8 +203,7 @@ } function setFavicon() { - document.getElementsByClassName("website-favicon")[0].src = - window.location.origin + '/favicon.ico'; + getFavicon(document.getElementsByClassName("website-favicon")[0]) }