From cc3464f5880ae55464144c40db5c6903b9d7a99b Mon Sep 17 00:00:00 2001 From: Carlos Polop Date: Mon, 21 Apr 2025 02:09:17 +0200 Subject: [PATCH] fix search --- theme/ht_searcher.js | 70 ++++++++++++++++++++++++++------------------ 1 file changed, 42 insertions(+), 28 deletions(-) diff --git a/theme/ht_searcher.js b/theme/ht_searcher.js index c27e9330e..f2b4de026 100644 --- a/theme/ht_searcher.js +++ b/theme/ht_searcher.js @@ -471,39 +471,53 @@ window.search = window.search || {}; showResults(true); } - (async function loadSearchIndex(lang = window.lang || 'en') { - /* ───────── paths ───────── */ - const branch = lang === 'en' ? 'master' : lang; - const baseRemote = `https://raw.githubusercontent.com/HackTricks-wiki/hacktricks-cloud/refs/heads/${branch}`; - const remoteJs = `${baseRemote}/searchindex.js`; - const localJs = '/searchindex.js'; - const TIMEOUT_MS = 5_000; - - const loadScript = src => - new Promise((resolve, reject) => { - const s = document.createElement('script'); - s.src = src; - s.onload = resolve; - s.onerror = reject; + (async function loadSearchIndex(lang = window.lang || "en") { + const branch = lang === "en" ? "master" : lang; + const rawUrl = + `https://raw.githubusercontent.com/HackTricks-wiki/hacktricks-cloud/refs/heads/${branch}/searchindex.js`; + const localJs = "/searchindex.js"; + const TIMEOUT_MS = 5_000; + + /* helper: inject a