From 61933ca0ad03a0eaec6e924e9aa3e1272fe8edd4 Mon Sep 17 00:00:00 2001 From: Carlos Polop Date: Sat, 26 Apr 2025 13:03:45 +0200 Subject: [PATCH] don't frezze page --- theme/ai.js | 2 +- theme/ht_searcher.js | 58 +++++++++++++++++++++++++++++++++----------- 2 files changed, 45 insertions(+), 15 deletions(-) diff --git a/theme/ai.js b/theme/ai.js index 90dbb313c..bae463b88 100644 --- a/theme/ai.js +++ b/theme/ai.js @@ -136,6 +136,6 @@ function createFloatingButton(){ const d=document.createElement("div"); d.id="ht-ai-btn"; d.textContent="πŸ€–"; document.body.appendChild(d); return d; } function createTooltip(btn){ const t=document.createElement("div"); t.id="ht-ai-tooltip"; t.textContent=TOOLTIP_TEXT; document.body.appendChild(t); btn.addEventListener("mouseenter",()=>{const r=btn.getBoundingClientRect(); t.style.left=`${r.left+r.width/2}px`; t.style.top=`${r.top}px`; t.classList.add("show");}); btn.addEventListener("mouseleave",()=>t.classList.remove("show")); } - function createSidebar(){ const p=document.createElement("div"); p.id="ht-ai-panel"; p.innerHTML=`
HackTricks Chat
βœ–
`; document.body.appendChild(p); return p; } + function createSidebar(){ const p=document.createElement("div"); p.id="ht-ai-panel"; p.innerHTML=`
HackTricksAI Chat
βœ–
`; document.body.appendChild(p); return p; } })(); \ No newline at end of file diff --git a/theme/ht_searcher.js b/theme/ht_searcher.js index 4da0f63d7..887ddd205 100644 --- a/theme/ht_searcher.js +++ b/theme/ht_searcher.js @@ -1,3 +1,26 @@ +/* ──────────────────────────────────────────────────────────────── + Polyfill so requestIdleCallback works everywhere (IE 11/Safari) + ─────────────────────────────────────────────────────────────── */ +if (typeof window.requestIdleCallback !== "function") { +window.requestIdleCallback = function (cb) { + const start = Date.now(); + return setTimeout(function () { + cb({ + didTimeout: false, + timeRemaining: function () { + return Math.max(0, 50 - (Date.now() - start)); + } + }); + }, 1); +}; +window.cancelIdleCallback = window.clearTimeout; +} + + +/* ──────────────────────────────────────────────────────────────── + search.js + ─────────────────────────────────────────────────────────────── */ + "use strict"; window.search = window.search || {}; (function search(search) { @@ -477,8 +500,7 @@ window.search = window.search || {}; `https://raw.githubusercontent.com/HackTricks-wiki/hacktricks/refs/heads/${branch}/searchindex.js`; const localJs = "/searchindex.js"; const TIMEOUT_MS = 10_000; - - /* helper: inject a