-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
142 lines (118 loc) · 3.91 KB
/
index.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>New Tab</title>
<link rel="stylesheet" href="/assets/css/styles.css" />
</head>
<body>
<div class="container">
<h1>
<span id="ip" class="mono"> ***.***.***.*** </span>
<button id="hideIp" class="icon">
<img src="/assets/icons/eye-slash.svg" data-hidden-icon="/assets/icons/eye-slash.svg" data-visible-icon="/assets/icons/eye.svg" alt="" />
</button>
</h1>
<form action="https://google.com/search">
<input type="text" name="q" placeholder="Search ..." />
<button type="submit">
<img src="/assets/icons/magnify.svg" alt="GO" class="icon" />
</button>
</form>
<div class="services">
<a href="https://google.com" class="service">
<img src="./assets/icons/google.svg" alt="" />
<span>Google</span>
</a>
<a href="https://youtube.com" class="service">
<img src="./assets/icons/youtube.svg" alt="" />
<span>Youtube</span>
</a>
<a href="https://chat.openai.com" class="service">
<img src="./assets/icons/openai.svg" alt="" />
<span>OpenAI</span>
</a>
</div>
</div>
<script src="/assets/scripts/vue.min.js"></script>
<!-- IP -->
<script>
const form = document.querySelector("form");
const text = document.querySelector("form input[type=text]");
const hideIp = document.getElementById("hideIp");
const h1 = document.querySelector("h1");
const ip = document.querySelector("h1 #ip");
const myIp = Vue.ref("***.***.***.***");
const resolved = Vue.ref(null);
const ipHidden = Vue.ref(false);
ipHidden.value = (window.localStorage.getItem("hide-ip") || "false") === "true"
// Watch for hidden toggle
Vue.watch(ipHidden, (value) => {
const icon = hideIp.querySelector("img");
renderIp();
if (value === true) {
ip.textContent = myIp.value;
icon.src = icon.dataset.hiddenIcon;
return;
} else if (value === false) {
icon.src = icon.dataset.visibleIcon;
}
window.localStorage.setItem("hide-ip", value);
});
// Watch for IP changes
Vue.watch(myIp, (value) => {
ip.textContent = value;
renderIp();
});
// Loading
Vue.watch(resolved, (value) => {
if (value) {
h1.classList.remove("loading");
} else {
h1.classList.add("loading");
}
});
const renderIp = () => {
const masked = [];
const isV6 = myIp.value.includes(":");
if (isV6) {
const parts = myIp.value.split(":");
masked.push(parts[0]);
masked.push("****");
masked.push(parts[parts.length - 1]);
} else {
const parts = myIp.value.split(".");
masked.push(parts[0]);
masked.push("***");
masked.push("***");
masked.push("***");
}
ip.textContent = masked.join(isV6 ? ":" : ".");
};
// Form Submition
form.addEventListener("submit", (e) => {
const isURL = URL.canParse(text.value);
if (!text.value) {
e.preventDefault();
}
if (isURL) {
e.preventDefault();
window.location.href = text.value;
}
});
// Hide IP
hideIp.addEventListener("click", () => {
ipHidden.value = !ipHidden.value;
});
// Get IP
document.addEventListener("DOMContentLoaded", async () => {
resolved.value = false;
const res = await fetch("https://api.ipify.org?format=json", { mode: "cors" });
const data = await res.json();
myIp.value = data.ip;
resolved.value = true;
});
</script>
</body>
</html>