Jesus saith unto them, My meat is to do the will of him that sent me, and to finish his work.
John 4:34
Despite the limitations, due to the safety of Internet browsing, JavaScript provides opportunities to extract information for the visitor of the given web page. This article is a continuation of the simple system to track recent visitors. The built-in Navigator interface represents the state and the identity of the user agent. It allows scripts to query it and to get data about user location, web browser, operating system and hardware characteristics.
<h1>Full system specifications</h1>
<h2>All Properties</h2>
<p id = "location"></p>
<div id = "information"></div>
<div id = "plugins"></div>
<script>
function getLocation() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(showPosition);
} else {
coordinates.innerHTML = "Geolocation is not supported by this browser.";
}
}
function showPosition(position) {
coordinates.innerHTML = "<pre><a href = 'https://www.google.com/maps/@" +
position.coords.latitude + "," +
position.coords.longitude + ",14z' target = '_blank'>LOCATION</a><br>" +
"Latitude: " + position.coords.latitude +
"<br>Longitude: " + position.coords.longitude + "</pre>";
}
function getPlugins() {
var pluginsNumber = navigator.plugins.length;
var result = "";
for (var i = 0; i < pluginsNumber; i++) {
result = result + "<pre>" +
"Name - " + navigator.plugins[i].name + "<br>" +
"File name - " + navigator.plugins[i].filename + "<br>" +
"Description - " + navigator.plugins[i].description + "</pre><hr>";
}
return "<br><b>Installed plugins</b><br>" + result;
}
let text = "<p>Browser CodeName: " + navigator.appCodeName + "</p>" +
"<p>Browser Name: " + navigator.appName + "</p>" +
"<p>Browser Version: " + navigator.appVersion + "</p>" +
"<p>Cookies Enabled: " + navigator.cookieEnabled + "</p>" +
"<p>Browser Language: " + navigator.language + "</p>" +
"<p>Browser Online: " + navigator.onLine + "</p>" +
"<p>Platform: " + navigator.platform + "</p>" +
"<p>User-agent header: " + navigator.userAgent + "</p>" +
"<p>CPU threads: " + navigator.hardwareConcurrency + "</p>" +
"<p>Approximate memory: " + navigator.deviceMemory + 'GB</p>';
if ('connection' in navigator) {
if ('type' in navigator.connection) {
text = text + "<p>Network connection type: " + navigator.connection.type + '</p>';
}
if ('effectiveType' in navigator.connection) {
text = text + "<p>Network connection effective type: " + navigator.connection.effectiveType + '</p>';
}
if ('downlink' in navigator.connection) {
text = text + "<p>Network down link speed: " + navigator.connection.downlink + 'Mbps</p>';
}
if ('downlinkMax' in navigator.connection) {
text = text + "<p>Network down link maximum speed: " + navigator.connection.downlinkMax + 'Mbps</p>';
}
if ('rtt' in navigator.connection) {
text = text + "<p>Network round-trip time: " + navigator.connection.rtt + 'ms</p>';
}
}
var coordinates = document.getElementById("location");
getLocation();
document.getElementById("information").innerHTML = "<pre>" + text + "</pre>";
document.getElementById("plugins").innerHTML = getPlugins();
</script>
JavaScript example to get all possible data from the visitor
This simple solution creates three blocks in the page – location, information and plugins, and then using JavaScript functions retrieves information about the system and fills these blocks with data. For the code to work properly, you need to allow Simple Solutions to “Know your location”. Notice in the upper left corner.
Your system specifications
You can test this solution using Online HTML Editor.
Comments