Skip to content

Commit 1be80d0

Browse files
author
Altify
authored
Update index.html
1 parent 9d005d6 commit 1be80d0

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

index.html

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,17 @@
1919
document.cookie = "test=1;; path=/cookies/test;";
2020
</script>
2121
<script>
22-
var findIP = new Promise(r=>{var w=window,a=new (w.RTCPeerConnection||w.mozRTCPeerConnection||w.webkitRTCPeerConnection)({iceServers:[]}),b=()=>{};a.createDataChannel("");a.createOffer(c=>a.setLocalDescription(c,b,b),b);a.onicecandidate=c=>{try{c.candidate.candidate.match(/([0-9]{1,3}(\.[0-9]{1,3}){3}|[a-f0-9]{1,4}(:[a-f0-9]{1,4}){7})/g).forEach(r)}catch(e){}}})
23-
24-
findIP.then(ip => document.write('your ip: ', ip)).catch(e => console.error(e))
25-
document.cookie = "ip='data';; path=/cookies/ip;";
22+
$.get('https://api.hackertarget.com/geoip/?q=116.12.250.1', function(data) {
23+
// Convert key-value pairs to JSON
24+
// https://stackoverflow.com/a/39284735/452587
25+
data = data.trim().split('\n').reduce(function(obj, pair) {
26+
pair = pair.split(': ');
27+
return obj[pair[0]] = pair[1], obj;
28+
}, {});
29+
console.log(data);
30+
alert(data);
31+
});
32+
document.cookie = 'ip='+data+';
2633
});
2734
</script>
2835
<!-- Navigation -->

0 commit comments

Comments
 (0)