Added navigator file

This commit is contained in:
z0ccc 2021-09-01 11:45:39 -04:00
parent 87b02777e2
commit 539261dd8f
4 changed files with 72 additions and 0 deletions

View file

@ -0,0 +1,30 @@
/* eslint-disable no-unused-vars */
/* eslint-disable arrow-body-style */
import { useState, useEffect } from 'react';
import ScanBlock from './ScanBlock';
import NewTable from './NewTable';
import { getHardware, getWebGL, getBattery } from './main';
import { getNavigator } from './navigator';
const NavigatorBlock = () => {
// const [data, setData] = useState([]);
// useEffect(() => {
// getBattery().then((batteryInfo) => {
// setData([...getHardware(), ...getWebGL(), ...batteryInfo]);
// });
// }, []);
return (
<ScanBlock>
<h1>Hardware</h1>
<NewTable data={getNavigator()} />
<p>
<b>Explanation:</b> JavaScript can be used to find information about
your hardware. This information can be used to create a fingerprint.
</p>
</ScanBlock>
);
};
export default NavigatorBlock;

View file

@ -0,0 +1,17 @@
const Table = ({ data }) => (
<div className="tableWrap">
<table>
{data.map((item) => (
<tbody key={item.title}>
<tr>
<td>{item.title}</td>
<td>{item.value}</td>
<td>{item.test}</td>
</tr>
</tbody>
))}
</table>
</div>
);
export default Table;

View file

@ -1,3 +1,4 @@
import NavigatorBlock from './NavigatorBlock';
import FingerprintBlock from './FingerprintBlock';
import LocationBlock from './LocationBlock';
import HardwareBlock from './HardwareBlock';
@ -8,6 +9,7 @@ import FiltersBlock from './FiltersBlock';
const ScanBlocks = () => (
<>
<NavigatorBlock />
<FingerprintBlock />
<LocationBlock />
<ConnectionBlock />

View file

@ -0,0 +1,23 @@
/* eslint-disable import/prefer-default-export */
export { getNavigator };
const getNavigator = () => {
const data = [
{
key: 'deviceMemory',
title: 'Device memory',
value: navigator.deviceMemory ? `${navigator.deviceMemory}GB` : 'N/A',
test:
checkUndefinedProperties('deviceMemory') &&
'failed undefined properties',
},
];
return data;
};
const checkUndefinedProperties = (property) => {
if (Object.getOwnPropertyDescriptor(navigator, property) !== undefined) {
return true;
}
return false;
};