|
| 1 | +/** |
| 2 | + * HackTricks Training Discounts |
| 3 | + */ |
| 4 | + |
| 5 | + |
| 6 | +(() => { |
| 7 | + const KEY = 'htSummerDiscountDismissed'; |
| 8 | + const IMG = '/images/discount.jpeg'; |
| 9 | + const TXT = 'HT Summer Discount, Last Days!'; |
| 10 | + |
| 11 | + /* Stop if user already dismissed */ |
| 12 | + if (localStorage.getItem(KEY) === 'true') return; |
| 13 | + |
| 14 | + /* Quick helper */ |
| 15 | + const $ = (tag, css = '') => Object.assign(document.createElement(tag), { style: css }); |
| 16 | + |
| 17 | + /* --- Overlay (blur + dim) --- */ |
| 18 | + const overlay = $('div', ` |
| 19 | + position: fixed; inset: 0; |
| 20 | + background: rgba(0,0,0,.4); |
| 21 | + backdrop-filter: blur(6px); |
| 22 | + display: flex; justify-content: center; align-items: center; |
| 23 | + z-index: 10000; |
| 24 | + `); |
| 25 | + |
| 26 | + /* --- Modal --- */ |
| 27 | + const modal = $('div', ` |
| 28 | + max-width: 90vw; width: 480px; |
| 29 | + background: #fff; border-radius: 12px; overflow: hidden; |
| 30 | + box-shadow: 0 8px 24px rgba(0,0,0,.35); |
| 31 | + font-family: system-ui, sans-serif; |
| 32 | + display: flex; flex-direction: column; align-items: stretch; |
| 33 | + `); |
| 34 | + |
| 35 | + /* --- Title bar (separate, over image) --- */ |
| 36 | + const titleBar = $('div', ` |
| 37 | + padding: 1rem; text-align: center; |
| 38 | + background: #222; color: #fff; |
| 39 | + font-size: 1.3rem; font-weight: 700; |
| 40 | + `); |
| 41 | + titleBar.textContent = TXT; |
| 42 | + |
| 43 | + /* --- Image --- */ |
| 44 | + const img = $('img'); |
| 45 | + img.src = IMG; img.alt = TXT; img.style.width = '100%'; |
| 46 | + |
| 47 | + /* --- Checkbox row --- */ |
| 48 | + const label = $('label', ` |
| 49 | + display: flex; align-items: center; justify-content: center; gap: .6rem; |
| 50 | + padding: 1rem; font-size: 1rem; color: #222; cursor: pointer; |
| 51 | + `); |
| 52 | + const cb = $('input'); cb.type = 'checkbox'; cb.style.scale = '1.2'; |
| 53 | + cb.onchange = () => { |
| 54 | + if (cb.checked) { |
| 55 | + localStorage.setItem(KEY, 'true'); |
| 56 | + overlay.remove(); |
| 57 | + } |
| 58 | + }; |
| 59 | + label.append(cb, document.createTextNode("Don't show again")); |
| 60 | + |
| 61 | + /* --- Assemble & inject --- */ |
| 62 | + modal.append(titleBar, img, label); |
| 63 | + overlay.appendChild(modal); |
| 64 | + |
| 65 | + (document.readyState === 'loading' |
| 66 | + ? () => document.addEventListener('DOMContentLoaded', () => document.body.appendChild(overlay), { once: true }) |
| 67 | + : () => document.body.appendChild(overlay))(); |
| 68 | +})(); |
| 69 | + |
| 70 | + |
| 71 | + |
| 72 | + |
1 | 73 | /**
|
2 | 74 | * HackTricks AI Chat Widget v1.16 – resizable sidebar
|
3 | 75 | * ---------------------------------------------------
|
4 | 76 | * ❶ Markdown rendering + sanitised (same as before)
|
5 | 77 | * ❷ NEW: drag‑to‑resize panel, width persists via localStorage
|
6 | 78 | */
|
| 79 | + |
| 80 | + |
| 81 | + |
7 | 82 | (function () {
|
8 |
| - const LOG = "[HackTricks‑AI]"; |
| 83 | + const LOG = "[HackTricks-AI]"; |
9 | 84 | /* ---------------- User‑tunable constants ---------------- */
|
10 | 85 | const MAX_CONTEXT = 3000; // highlighted‑text char limit
|
11 | 86 | const MAX_QUESTION = 500; // question char limit
|
12 | 87 | const MIN_W = 250; // ← resize limits →
|
13 | 88 | const MAX_W = 600;
|
14 | 89 | const DEF_W = 350; // default width (if nothing saved)
|
15 | 90 | const TOOLTIP_TEXT =
|
16 |
| - "💡 Highlight any text on the page,\nthen click to ask HackTricks AI about it"; |
| 91 | + "💡 Highlight any text on the page,\nthen click to ask HackTricks AI about it"; |
17 | 92 |
|
18 | 93 | const API_BASE = "https://www.hacktricks.ai/api/assistants/threads";
|
19 | 94 | const BRAND_RED = "#b31328";
|
|
0 commit comments