|
4 | 4 |
|
5 | 5 |
|
6 | 6 | (() => { |
7 | | - const KEY = 'htSummerDiscountDismissed'; |
8 | | - const IMG = '/images/discount.jpeg'; |
9 | | - const TXT = 'HT Summer Discount, Last Days!'; |
| 7 | + const KEY = 'htSummerDiscountsDismissed'; |
| 8 | + const IMG = '/images/discount.jpeg'; |
| 9 | + const TXT = 'Click here for HT Summer Discounts, Last Days!'; |
| 10 | + const URL = 'https://training.hacktricks.xyz'; |
10 | 11 |
|
11 | 12 | /* Stop if user already dismissed */ |
12 | 13 | if (localStorage.getItem(KEY) === 'true') return; |
|
32 | 33 | display: flex; flex-direction: column; align-items: stretch; |
33 | 34 | `); |
34 | 35 |
|
35 | | - /* --- Title bar (separate, over image) --- */ |
| 36 | + /* --- Title bar (link + close) --- */ |
36 | 37 | const titleBar = $('div', ` |
37 | | - padding: 1rem; text-align: center; |
| 38 | + position: relative; |
| 39 | + padding: 1rem 2.5rem 1rem 1rem; /* room for the close button */ |
| 40 | + text-align: center; |
38 | 41 | background: #222; color: #fff; |
39 | 42 | font-size: 1.3rem; font-weight: 700; |
40 | 43 | `); |
41 | | - titleBar.textContent = TXT; |
| 44 | + |
| 45 | + const link = $('a', ` |
| 46 | + color: inherit; |
| 47 | + text-decoration: none; |
| 48 | + display: block; |
| 49 | + `); |
| 50 | + link.href = URL; |
| 51 | + link.target = '_blank'; |
| 52 | + link.rel = 'noopener noreferrer'; |
| 53 | + link.textContent = TXT; |
| 54 | + titleBar.appendChild(link); |
| 55 | + |
| 56 | + /* Close "X" (no persistence) */ |
| 57 | + const closeBtn = $('button', ` |
| 58 | + position: absolute; top: .25rem; right: .5rem; |
| 59 | + background: transparent; border: none; |
| 60 | + color: #fff; font-size: 1.4rem; line-height: 1; |
| 61 | + cursor: pointer; padding: 0; margin: 0; |
| 62 | + `); |
| 63 | + closeBtn.setAttribute('aria-label', 'Close'); |
| 64 | + closeBtn.textContent = '✕'; |
| 65 | + closeBtn.onclick = () => overlay.remove(); |
| 66 | + titleBar.appendChild(closeBtn); |
42 | 67 |
|
43 | 68 | /* --- Image --- */ |
44 | 69 | const img = $('img'); |
|
62 | 87 | modal.append(titleBar, img, label); |
63 | 88 | overlay.appendChild(modal); |
64 | 89 |
|
65 | | - (document.readyState === 'loading' |
66 | | - ? () => document.addEventListener('DOMContentLoaded', () => document.body.appendChild(overlay), { once: true }) |
67 | | - : () => document.body.appendChild(overlay))(); |
| 90 | + if (document.readyState === 'loading') { |
| 91 | + document.addEventListener('DOMContentLoaded', () => document.body.appendChild(overlay), { once: true }); |
| 92 | + } else { |
| 93 | + document.body.appendChild(overlay); |
| 94 | + } |
68 | 95 | })(); |
69 | 96 |
|
70 | 97 |
|
|
0 commit comments