Skip to content

Commit 5bca01e

Browse files
committed
discount
1 parent 7c922d4 commit 5bca01e

File tree

1 file changed

+77
-2
lines changed

1 file changed

+77
-2
lines changed

theme/ai.js

Lines changed: 77 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,94 @@
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+
173
/**
274
* HackTricks AI Chat Widget v1.16 – resizable sidebar
375
* ---------------------------------------------------
476
* ❶ Markdown rendering + sanitised (same as before)
577
* ❷ NEW: drag‑to‑resize panel, width persists via localStorage
678
*/
79+
80+
81+
782
(function () {
8-
const LOG = "[HackTricksAI]";
83+
const LOG = "[HackTricks-AI]";
984
/* ---------------- User‑tunable constants ---------------- */
1085
const MAX_CONTEXT = 3000; // highlighted‑text char limit
1186
const MAX_QUESTION = 500; // question char limit
1287
const MIN_W = 250; // ← resize limits →
1388
const MAX_W = 600;
1489
const DEF_W = 350; // default width (if nothing saved)
1590
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";
1792

1893
const API_BASE = "https://www.hacktricks.ai/api/assistants/threads";
1994
const BRAND_RED = "#b31328";

0 commit comments

Comments
 (0)