-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
69 lines (58 loc) · 1.71 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
<title>iphistory tool</title>
<script>
function show_ip_history() {
var data = localStorage.ip_history;
if (data) {
data = JSON.parse(data);
console.log(data);
}
}
function append_ip() {
var data = localStorage.ip_history;
if (data) {
data = JSON.parse(data);
} else {
data = []
}
}
function get_ip() {
// Creating Our XMLHttpRequest object
let xhr = new XMLHttpRequest();
// Making our connection
let url = 'https://ifconfig.me/ip';
xhr.open("GET", url, true);
// function execute after request is successful
xhr.onreadystatechange = function () {
if (this.readyState == 4 && this.status == 200) {
console.log(this.responseText);
// Append to data
show_ip_history();
const newNode = document.createElement("div");
newNode.style.textAlign = "center";
newNode.innerHTML = new Date().toISOString() + ': <span style="color:red;">' + this.responseText + '</span>';
document.body.insertBefore(newNode, document.body.firstChild);
}
}
// Sending our request
xhr.send();
}
show_ip_history();
get_ip();
const urlParams = new URLSearchParams(window.location.search);
let interval = urlParams.get('interval');
if (interval) {
interval = parseInt(interval) * 1000;
} else {
interval = 10000;
document.location.search = "interval=10"
}
setInterval(get_ip, interval);
</script>
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-97SPTYXEX0"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-97SPTYXEX0');
</script>