-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
80 lines (75 loc) · 2.68 KB
/
main.js
File metadata and controls
80 lines (75 loc) · 2.68 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
// ==UserScript==
// @name Azar IP Scanner Mobile
// @namespace https://github.com/VeltrixJS/Azarlive-IP-Scanner
// @version 3.0
// @description Mobile IP Tracker for Azar
// @author VeltrixJS
// @match https://azarlive.com/*
// @grant none
// ==/UserScript==
(function(){
'use strict';
const box = document.createElement('div');
box.style.cssText = 'position:fixed;bottom:10px;left:10px;max-width:350px;background:#121212;border:2px solid #51f59b;border-radius:10px;padding:15px;z-index:9999;color:#fff;font:15px Arial;cursor:move;';
box.innerHTML = '<div id="ip-data" style="text-align:center;color:#51f59b;font-size:16px;">Waiting for connection...</div>';
document.body.appendChild(box);
let pos={x:0,y:0,startX:0,startY:0};
box.onmousedown = box.ontouchstart = (e) => {
e.preventDefault();
const evt = e.touches ? e.touches[0] : e;
pos.startX = evt.clientX - box.offsetLeft;
pos.startY = evt.clientY - box.offsetTop;
document.onmousemove = document.ontouchmove = (e) => {
const evt = e.touches ? e.touches[0] : e;
box.style.left = (evt.clientX - pos.startX) + 'px';
box.style.top = (evt.clientY - pos.startY) + 'px';
box.style.bottom = 'auto';
};
document.onmouseup = document.ontouchend = () => {
document.onmousemove = document.ontouchmove = null;
};
};
const fetchIP = async(ip) => {
try {
const r = await fetch(`http://ip-api.com/json/${ip}`);
const d = await r.json();
if(d.status === 'success') return {city:d.city,region:d.regionName,zip:d.zip,country:d.country,isp:d.isp};
} catch(e) {}
try {
const r = await fetch(`https://ipapi.co/${ip}/json/`);
const d = await r.json();
if(!d.error) return {city:d.city,region:d.region,zip:d.postal,country:d.country_name,isp:d.org};
} catch(e) {}
return null;
};
let current = null;
const orig = window.RTCPeerConnection;
window.RTCPeerConnection = function(...args) {
const pc = new orig(...args);
const add = pc.addIceCandidate;
pc.addIceCandidate = async function(ice,...rest) {
if(ice?.candidate) {
const f = ice.candidate.split(' ');
if(f[7]==='srflx') {
const ip = f[4];
if(current !== ip) {
current = ip;
const data = await fetchIP(ip);
if(data) {
const dept = data.zip ? data.zip.substring(0,2) : '??';
document.getElementById('ip-data').innerHTML = `
<div style="margin:6px 0;font-size:15px"><b style="color:#51f59b">IP:</b> ${ip}</div>
<div style="margin:6px 0;font-size:15px"><b style="color:#51f59b">ISP:</b> ${data.isp||'N/A'}</div>
<div style="margin:6px 0;font-size:15px"><b style="color:#51f59b">LOC:</b> ${data.city}, ${data.region} (${dept})</div>
`;
} else {
document.getElementById('ip-data').innerHTML = `<div style="color:#51f59b;font-size:15px"><b>IP:</b> ${ip}<br><b>Location:</b> Unknown</div>`;
}
}
}
}
return add.call(this,ice,...rest);
};
return pc;
};
})();