forked from LISplaysYT/LoungeF2X
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtabs.html
More file actions
427 lines (404 loc) · 15.9 KB
/
tabs.html
File metadata and controls
427 lines (404 loc) · 15.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Home</title>
<link rel="stylesheet" href="/static/style.css">
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css" rel="stylesheet">
<script src="/static/tabcloaker.js"></script>
<meta name="google-adsense-account" content="ca-pub-8655131518824482">
<script>
document.addEventListener("DOMContentLoaded", () => {
cloakAll();
const savedURL = localStorage.getItem("url");
const Url = decodeURIComponent(savedURL);
if (savedURL) {
const firstIframe = document.querySelector(".tab-iframe.active");
if (firstIframe) {
firstIframe.src = `${Url}`;
localStorage.removeItem("url");
}
}
});
</script>
<script async src="https://www.googletagmanager.com/gtag/js?id=G-JC8E4VJGL9"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag() { dataLayer.push(arguments); }
gtag('js', new Date());
gtag('config', 'G-JC8E4VJGL9');
</script>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body, html {
height: 100%;
overflow: hidden;
display: flex;
flex-direction: column;
}
.tabs {
display: flex;
align-items: center;
background-color: #222;
border-bottom: 2px solid #FF0000;
overflow: hidden;
white-space: nowrap;
transition: transform 0.5s ease-in-out;
}
.tab {
display: flex;
align-items: center;
padding: 5px 10px;
color: #ccc;
cursor: pointer;
position: relative;
background-color: #333;
border-right: 1px solid #555;
transition: background-color 0.3s;
flex-shrink: 1;
max-width: 150px;
overflow: hidden;
border-radius: 5px;
text-overflow: ellipsis;
}
.tab.active {
background-color: #444;
color: #FF0000;
}
.tab:hover {
background-color: #555;
}
.tab .close-button {
margin-left: 5px;
color: #ccc;
cursor: pointer;
font-size: 14px;
}
.tab .close-button:hover {
color: #262626;
}
.add-tab-button {
padding: 10px;
cursor: pointer;
background-color: #333;
color: #FF0000;
border: none;
outline: none;
font-size: 20px;
}
.navbarmain {
display: flex;
align-items: center;
justify-content: space-between;
background-color: #333;
padding: 10px;
width: 100%;
border-bottom: 2px solid #FF0000;
transition: transform 0.5s ease-in-out;
}
.navbarmain-left {
display: flex;
gap: 10px;
}
.navbarmain button {
background: transparent;
border: none;
color: #FF0000;
cursor: pointer;
font-size: 20px;
}
.navbarmain button:hover {
color: #fff;
}
.search-bar {
flex-grow: 1;
display: flex;
align-items: center;
border-radius: 25px;
background-color: #000;
border: 2px solid #FF0000;
overflow: hidden;
height: 30px;
margin-left: 20px;
}
.search-bar input {
flex-grow: 1;
padding: 10px;
border: none;
background-color: transparent;
color: #ccc;
font-size: 16px;
}
.search-bar input:focus {
outline: none;
}
.search-bar button {
background-color: #FF0000;
border: none;
padding: 10px 20px;
font-size: 16px;
color: #000;
cursor: pointer;
display: flex;
align-items: center;
border-radius: 0 25px 25px 0;
}
.search-bar button i {
margin-left: 5px;
}
.content-wrapper {
flex-grow: 1;
overflow: hidden;
position: relative;
height: 100%;
}
iframe {
width: 100%;
height: 100%;
border: none;
display: none;
}
iframe.active {
display: block;
}
.hide-button {
position: fixed;
top: 10px;
right: 10px;
background-color: transparent;
border: none;
font-size: 30px;
color: #FF0000;
cursor: pointer;
z-index: 1001;
}
.navbar.hidden, .tabs.hidden {
transform: translateY(-200%);
}
.show-navbar-button {
position: fixed;
top: 10px;
right: 10px;
background-color: transparent;
border: none;
font-size: 30px;
color: white;
cursor: pointer;
display: none;
z-index: 2000;
}
.show-navbar-button i {
color: #FF0000;
}
</style>
</head>
<body>
<div class="tabs" id="tabs">
<div class="tab active" onclick="selectTab(this)">New Tab <span class="close-button" onclick="closeTab(event, this)">×</span></div>
<button class="add-tab-button" onclick="addTab()">+</button>
</div>
<div class="navbarmain" id="navbar">
<div class="navbarmain-left">
<button onclick="home()"><i class="fa fa-home"></i></button>
<button onclick="document.querySelector('.tab-iframe.active').contentWindow.history.back()"><i class="fas fa-arrow-left"></i></button>
<button onclick="document.querySelector('.tab-iframe.active').contentWindow.history.forward()"><i class="fas fa-arrow-right"></i></button>
<button onclick="document.querySelector('.tab-iframe.active').contentWindow.location.reload()"><i class="fas fa-redo"></i></button>
<button onclick="goFullscreen()"><i class="fa-solid fa-expand"></i></button>
<button onclick="eToggle()"><i class="fa-solid fa-code"></i></button>
</div>
<div class="search-bar">
<input type="text" id="search-input" placeholder="Search or enter a URL" onkeydown="if(event.key === 'Enter') search()">
<button onclick="search()">
SEARCH <i class="fas fa-search"></i>
</button>
</div>
</div>
<div class="content-wrapper" id="content-wrapper">
<iframe class="tab-iframe active" src="/static/embed.html#https://google.com" id="iframe-1"></iframe>
</div>
<script>
function goFullscreen() {
const element = document.querySelector('.tab-iframe.active')
if (element.requestFullscreen) {
element.requestFullscreen().catch((err) => {
console.error(`Failed to enter fullscreen mode: \${err.message}`);
});
} else if (element.mozRequestFullScreen) { // Firefox
element.mozRequestFullScreen().catch((err) => {
console.error(`Failed to enter fullscreen mode: \${err.message}`);
});
} else if (element.webkitRequestFullscreen) { // Older WebKit
element.webkitRequestFullscreen();
} else if (element.msRequestFullscreen) { // IE/Edge
element.msRequestFullscreen();
} else {
console.error("Fullscreen API is not supported on this browser.");
}
}
let tabCount = 1;
function selectTab(tabElement) {
document.querySelectorAll('.tab').forEach(tab => tab.classList.remove('active'));
document.querySelectorAll('.tab-iframe').forEach(tabiframe => tabiframe.classList.remove('active'));
tabElement.classList.add('active');
const tabIndex = [...tabElement.parentElement.children].indexOf(tabElement);
const tabiframe = document.querySelectorAll('.tab-iframe')[tabIndex];
tabiframe.classList.add('active');
}
function observeIframe(iframe, tabElement) {
const observer = new MutationObserver(() => {
try {
const title = iframe.contentWindow.document.title || 'Google';
tabElement.textContent = title.substring(0, 15);
tabElement.innerHTML += ' <span class="close-button" onclick="closeTab(event, this)">×</span>';
} catch (error) {
tabElement.textContent = 'Google';
tabElement.innerHTML += ' <span class="close-button" onclick="closeTab(event, this)">×</span>';
}
});
observer.observe(iframe, { attributes: true, attributeFilter: ['src'] });
iframe.onload = () => {
try {
const title = iframe.contentWindow.document.title || 'New Tab';
tabElement.textContent = title.substring(0, 15);
tabElement.innerHTML += ' <span class="close-button" onclick="closeTab(event, this)">×</span>';
// Override window.open to force opening in the same iframe (or window)
const originalWindowOpen = iframe.contentWindow.open;
iframe.contentWindow.open = function(url, target, features) {
if (target === '_blank') {
// Open the link in the same iframe
iframe.src = url;
} else {
// If not _blank, use the original open behavior
originalWindowOpen.call(iframe.contentWindow, url, target, features);
}
};
} catch (error) {
tabElement.textContent = 'New Tab';
tabElement.innerHTML += ' <span class="close-button" onclick="closeTab(event, this)">×</span>';
}
};
}
function addTab(url) {
tabCount++;
const tabsContainer = document.getElementById('tabs');
const iframe = document.createElement('iframe');
const newTab = document.createElement('div');
newTab.classList.add('tab');
newTab.textContent = "Loading...";
newTab.innerHTML += ' <span class="close-button" onclick="closeTab(event, this)">×</span>';
newTab.onclick = () => selectTab(newTab);
tabsContainer.insertBefore(newTab, document.querySelector('.add-tab-button'));
if (!url) {
url = "https://google.com"
}
iframe.classList.add('tab-iframe');
iframe.id = `iframe-${tabCount}`;
iframe.src = `/static/embed.html#${url}`;
document.getElementById('content-wrapper').appendChild(iframe);
// Observe iframe changes and update the tab name
observeIframe(iframe, newTab);
}
function closeTab(event, closeButton) {
event.stopPropagation();
const tab = closeButton.parentElement;
if (tab.classList.contains('active')) {
const nextTab = tab.nextElementSibling || tab.previousElementSibling;
if (nextTab) selectTab(nextTab);
}
tab.remove();
document.getElementById(`iframe-${tab.dataset.tabId}`).remove();
}
function updateTabName(iframe, tabElement) {
iframe.onload = () => {
try {
const title = iframe.contentWindow.document.title || 'New Tab';
tabElement.textContent = title.substring(0, 15);
tabElement.innerHTML += ' <span class="close-button" onclick="closeTab(event, this)">×</span>';
} catch (error) {
tabElement.textContent = 'New Tab';
tabElement.innerHTML += ' <span class="close-button" onclick="closeTab(event, this)">×</span>';
}
};
}
function search() {
const inputElement = document.getElementById('search-input');
const input = inputElement.value.trim();
const activeIframe = document.querySelector('.tab-iframe.active');
if (!input) return; // Do nothing if the input is empty.
/**
* Determines the appropriate URL for navigation.
* @param {string} input
* @param {string} template Template for a search query.
* @returns {string} Fully qualified URL or search query URL.
*/
function detectURL(input, template) {
// If the input ends with a space, treat it as a search query
if (input.includes(" ") && !input.startsWith("http")) {
return template.replace("%s", encodeURIComponent(input));
}
try {
// Check if input is a valid URL
return new URL(input).toString();
} catch (err) {}
try {
// Check if input becomes a valid URL with "http://" prefix
const url = new URL(`http://${input}`);
if (url.hostname.includes(".")) return url.toString();
} catch (err) {}
// If all URL checks fail, treat it as a search query
return template.replace("%s", encodeURIComponent(input));
}
// Use the function to decide
const url = detectURL(input, "https://www.google.com/search?q=%s");
// Redirect to appropriate iframe source
activeIframe.src = url.startsWith("http") ? `/static/embed.html#${url}` : url;
}
function home() {
window.location.href = "/static/"
}
function eToggle() {
const activeIframe = document.querySelector(".tab-iframe.active");
if (!activeIframe) {
console.error("No active iframe found");
return;
}
const erudaWindow = activeIframe.contentWindow;
if (!erudaWindow) {
console.error("No content window found for the active iframe");
return;
}
if (erudaWindow.eruda) {
if (erudaWindow.eruda._isInit) {
erudaWindow.eruda.destroy();
} else {
console.error("Eruda is not initialized in the active iframe");
erudaWindow.eruda.init();
erudaWindow.eruda.show();
}
} else {
const erudaDocument = activeIframe.contentDocument;
if (!erudaDocument) {
console.error("No content document found for the active iframe");
return;
}
const script = erudaDocument.createElement("script");
script.src = "https://cdn.jsdelivr.net/npm/eruda";
script.onload = () => {
if (!erudaWindow.eruda) {
console.error("Failed to load Eruda in the active iframe");
return;
}
erudaWindow.eruda.init();
erudaWindow.eruda.show();
};
erudaDocument.head.appendChild(script);
}
}
</script>
</body>
</html>