|
2 | 2 | <html lang="en"> |
3 | 3 | <head> |
4 | 4 | <meta charset="UTF-8"> |
5 | | - <title>Search in New Tab</title> |
| 5 | + <title>Endless Search Tabs</title> |
6 | 6 | </head> |
7 | 7 | <body> |
8 | | - <p>Opening search in a new tab…</p> |
| 8 | + <p>Opening Bing searches in new tabs every 5–8 seconds…</p> |
| 9 | + <p id="counter" style="color:gray;"></p> |
| 10 | + |
9 | 11 | <script> |
10 | | - if (!sessionStorage.getItem('opened')) { |
11 | | - sessionStorage.setItem('opened', '1'); |
| 12 | + // Prevent multiple loops if the page is reloaded |
| 13 | + if (sessionStorage.getItem('loopActive')) { |
| 14 | + document.body.innerHTML += '<p style="color:red">Loop already running in this session. Close this tab.</p>'; |
| 15 | + } else { |
| 16 | + sessionStorage.setItem('loopActive', '1'); |
12 | 17 |
|
13 | 18 | const keywords = [ |
14 | 19 | 'javascript', 'python', 'algorithm', 'database', 'cloud', |
|
18 | 23 | 'network', 'cryptography', 'compiler', 'debugging', 'performance' |
19 | 24 | ]; |
20 | 25 |
|
21 | | - const count = Math.floor(Math.random() * 3) + 3; // 3, 4, or 5 |
22 | | - const shuffled = keywords.sort(() => Math.random() - 0.5); |
23 | | - const selected = shuffled.slice(0, count); |
24 | | - const query = selected.join(' '); |
| 26 | + let tabCount = 0; |
| 27 | + const counterEl = document.getElementById('counter'); |
| 28 | + |
| 29 | + function openSearchTab() { |
| 30 | + // Pick 3–5 random keywords |
| 31 | + const count = Math.floor(Math.random() * 3) + 3; // 3, 4, or 5 |
| 32 | + const shuffled = keywords.sort(() => Math.random() - 0.5); |
| 33 | + const selected = shuffled.slice(0, count); |
| 34 | + const query = selected.join(' '); |
| 35 | + const url = 'https://www.bing.com/search?q=' + encodeURIComponent(query); |
| 36 | + |
| 37 | + // Open in new tab |
| 38 | + window.open(url, '_blank'); |
| 39 | + |
| 40 | + // Update counter |
| 41 | + tabCount++; |
| 42 | + counterEl.textContent = `Tabs opened: ${tabCount}`; |
| 43 | + |
| 44 | + // Schedule next opening after 5–8 seconds |
| 45 | + const delay = Math.floor(Math.random() * 3001) + 5000; // 5000–8000 ms |
| 46 | + setTimeout(openSearchTab, delay); |
| 47 | + } |
25 | 48 |
|
26 | | - const url = 'https://www.bing.com/search?q=' + encodeURIComponent(query); |
27 | | - window.open(url, '_blank'); |
| 49 | + // Start the loop immediately (or after a short initial delay if preferred) |
| 50 | + openSearchTab(); |
28 | 51 | } |
29 | 52 | </script> |
30 | 53 | </body> |
|
0 commit comments