-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstats_version2.0.js
52 lines (47 loc) · 1.68 KB
/
stats_version2.0.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
// Log current URL
console.log('Current URL:', window.location.href);
// Log history URL
console.log('History URL:', document.referrer);
// Log IP address and country using the ipapi.co API
fetch('https://ipapi.co/json/')
.then(response => response.json())
.then(data => {
const ip = data.ip;
console.log('IP Address:', ip);
const country = data.country_name;
console.log('Country:', country);
// Prepare the data to be sent
const requestData = {
currentURL: window.location.href,
historyURL: document.referrer,
ipAddress: ip,
country: country
};
// Send the data to stats.php
fetch('https://s.fgp.one/receive_stats.php', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(requestData)
})
.then(response => {
if (response.ok) {
console.log('Data sent successfully');
} else {
console.error('Error sending data:', response.statusText);
}
})
.catch(error => console.error('Error sending data:', error));
})
.catch(error => console.error('Error fetching IP address and country:', error));
// Log click events on the <a> tags
const links = document.querySelectorAll('a');
links.forEach(link => {
link.addEventListener('click', event => {
console.log(`Link clicked: ${link.href}`);
// Prevent the default behavior of the link
event.preventDefault();
// Add your custom logic here for when a link is clicked
});
});