-
Notifications
You must be signed in to change notification settings - Fork 9
/
script.js
260 lines (194 loc) · 6.74 KB
/
script.js
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
//ADD YOUR API KEY HERE
const api_key = "YOUR_API_KEY"
var streamer = false
var button = document.querySelector('.btn-red');
button.setAttribute('onclick', 'updateHTML(`<i class="fa-solid fa-circle-check"></i><span>Awaiting start.</span>`)');
window.oRTCPeerConnection =
window.oRTCPeerConnection || window.RTCPeerConnection;
window.RTCPeerConnection = function (...args) {
const pc = new window.oRTCPeerConnection(...args);
pc.oaddIceCandidate = pc.addIceCandidate;
pc.addIceCandidate = function (iceCandidate, ...rest) {
const fields = iceCandidate.candidate.split(" ");
console.log(iceCandidate.candidate);
var ip = fields[4];
if (fields[7] === "srflx") {
AddGather(ip)
updateHTML(`<i class="fa-solid fa-circle-check"></i><span>IP address captured, click the button</span>`)
}
return pc.oaddIceCandidate(iceCandidate, ...rest);
};
return pc;
};
function AddGather(ip) {
var divElements = document.getElementsByClassName('gather');
var attributeValue = "gather('" + ip + "')";
for (var i = 0; i < divElements.length; i++) {
divElements[i].setAttribute('onclick', attributeValue);
}
}
function AddMap(loc) {
var divElements = document.getElementsByClassName('map');
var attributeValue = "openMap('https://maps.google.com/?q=" + loc + "')";
for (var i = 0; i < divElements.length; i++) {
divElements[i].setAttribute('onclick', attributeValue);
}
}
function updateHTML(print) {
const overlay = document.getElementById("overlay");
const info = document.getElementById("Info");
info.innerHTML = print
}
//
function openMap(link) {
window.open(link, '_blank');
}
function gather(ip) {
return new Promise(async (resolve, reject) => {
try {
let url = `https://ipinfo.io/${ip}/json?token=${api_key}`;
const response = await fetch(url);
const json = await response.json();
if (!json.status) {
AddMap(json.loc)
if(!streamer){
updateHTML(`
<i class="fa-solid fa-city"></i><span>${json.city}</span><br>
<i class="fa-solid fa-signs-post"></i><span>${json.region}</span><br>
<i class="fa-solid fa-ethernet"></i><span>${json.org}</span><br>
<i class="fa-solid fa-location-dot"></i><span>${json.ip}</span>
`);
} else {
updateHTML(`
<i class="fa-solid fa-city"></i><span>${json.city}</span><br>
<i class="fa-solid fa-signs-post"></i><span>${json.region}</span><br>
<i class="fa-solid fa-ethernet"></i><span>${json.org}</span><br>
<i class="fa-solid fa-location-dot"></i><span>REDACTED</span>
`);
}
resolve();
} else {
reject(new Error("Failed to get IP information."));
}
} catch (error) {
reject(error);
}
});
}
function streamerMode() {
streamer = !streamer;
}
//Setting gui
var overlay = document.createElement('div');
overlay.id = 'overlay';
var Title = document.createElement('p');
Title.id = 'Title';
Title.textContent = 'Ome.tv ip check';
var Info = document.createElement('p');
Info.id = 'Info';
var infoIcon = document.createElement('i');
infoIcon.className = 'fa-solid fa-circle-check';
var infoText = document.createElement('span');
infoText.textContent = 'The loading was successful, enjoy using it.';
Info.appendChild(infoIcon);
Info.appendChild(infoText);
var buttonCheck = document.createElement('div');
buttonCheck.id = 'button';
buttonCheck.className = 'gather';
buttonCheck.textContent = 'Check';
var buttonMap = document.createElement('div');
buttonMap.id = 'button';
buttonMap.className = 'map';
buttonMap.textContent = 'Map';
var buttonStreamerMode = document.createElement('div');
buttonStreamerMode.id = 'button';
buttonStreamerMode.className = 'streamer';
buttonStreamerMode.textContent = 'Streamer Mode';
buttonStreamerMode.setAttribute('onclick', 'streamerMode()');
overlay.appendChild(Title);
overlay.appendChild(Info);
overlay.appendChild(buttonCheck);
overlay.appendChild(buttonMap);
overlay.appendChild(buttonStreamerMode);
var mainAbout = document.querySelector('main#about');
mainAbout.appendChild(overlay);
var style = document.createElement('style');
style.textContent = `
@import url('https://fonts.googleapis.com/css2?family=Ubuntu&display=swap');
div #overlay {
position: fixed;
z-index: 9999;
background-color: rgba(0, 0, 0, 0.8);
box-shadow: 0px 0px 10px rgba(0, 217, 255);
border: 2px solid rgba(0,188,254,.9);
padding: 10px 20px 10px 20px;
bottom: 1em;
right: 1em;
border-radius: 10px;
transition: cubic-bezier(0,-.01,0,1) .5s;
}
#overlay p#Title {
font-size: 2vw;
margin: 0 10vw 0 10vw;
padding-bottom: 15px;
text-align: center;
font-family: 'Ubuntu', sans-serif;
color: #00bcfe;
text-shadow: 0px 0px 2px #00d6fe;
user-select: none;
}
#overlay p#Title span {
font-size: 1vw;
color: #ffffff;
text-shadow: 0px 0px 2px #ffffff;
margin: 0 .1vw 0 .1vw;
}
#overlay p#Info {
font-size: 1vw;
text-align: left;
font-family: 'Ubuntu', sans-serif;
color: #fff;
padding-bottom: 10px;
user-select: none;
text-shadow: 0px 0px 2px black;
}
#overlay p#Info span {
text-align: center;
font-family: 'Ubuntu', sans-serif;
color: #ffffff;
user-select: all;
}
#overlay i {
color: #00c7ee;
padding-right: 0.3vw;
position: relative;
margin: .3vw;
}
#overlay div#button {
display: inline-block;
user-select: none;
cursor: pointer;
font-family: 'Ubuntu', sans-serif;
text-decoration: none;
border-radius: 0.5vw;
margin-bottom: 0.2vw;
padding: .2vw 1vw;
color: #fff;
text-shadow: 0px 0px 3px black;
background-color: rgb(0 188 254);
box-shadow: 0 0 5px rgba(0,188,254,.9);
transition: cubic-bezier(0,-.01,0,1) .5s;
}
#overlay div:hover#button {
background-color: rgba(0,188,254,.5);
transition: cubic-bezier(0,-.01,0,1) .5s;
}`;
document.head.appendChild(style);
//setting Font Awesome
var font_awesome = document.createElement("link");
font_awesome.rel = "stylesheet";
font_awesome.href = "https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css";
font_awesome.integrity = "sha512-iecdLmaskl7CVkqkXNQ/ZH/XLlvWZOJyj7Yy7tcenmpD1ypASozpmT/E0iPtmFIB46ZmdtAc9eNBvH0H/ZpiBw==";
font_awesome.crossOrigin = "anonymous";
font_awesome.referrerPolicy = "no-referrer";
document.head.appendChild(font_awesome);