From 392d61eb154bb284768a20815b2d58d9d9734182 Mon Sep 17 00:00:00 2001 From: Bobby <30593201+luciferreeves@users.noreply.github.com> Date: Wed, 17 Dec 2025 17:39:48 +0530 Subject: Early exit for unsupported file types --- head-include.html | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'head-include.html') diff --git a/head-include.html b/head-include.html index 17e06b5..8e05195 100644 --- a/head-include.html +++ b/head-include.html @@ -64,11 +64,14 @@ * The hex dump is moved into a
block below the image. */ function enhanceBlobPreview() { - const content = document.querySelector("div.content"); const binBlob = document.querySelector("table.bin-blob"); - const plainLink = document.querySelector('a[href*="/plain/"]'); + if (!binBlob) return; - if (!content || !binBlob || !plainLink) return; + const plainLink = document.querySelector('a[href*="/plain/"]'); + if (!plainLink) { + binBlob.style.display = "table"; + return; + } const url = plainLink.getAttribute("href"); const ext = getFileExtension(url); @@ -78,20 +81,23 @@ return; } + const content = document.querySelector("div.content"); + if (!content) { + binBlob.style.display = "table"; + return; + } + const img = new Image(); img.src = url; img.alt = "Rendered image"; img.onload = () => { - // Image preview const preview = document.createElement("div"); preview.className = "cgit-image-preview"; preview.appendChild(img); - // Insert preview before hex dump content.insertBefore(preview, binBlob); - // Wrap hex dump in
const details = document.createElement("details"); details.className = "cgit-hexdump"; -- cgit v1.2.3