Fixed issues handling

This commit is contained in:
z0ccc 2021-09-07 16:30:59 -04:00
parent fc5edc6c22
commit 5aa08c53c3
4 changed files with 135 additions and 64 deletions

View file

@ -38,5 +38,6 @@ module.exports = {
'react/prop-types': 'off', 'react/prop-types': 'off',
'react/react-in-jsx-scope': 'off', 'react/react-in-jsx-scope': 'off',
'no-bitwise': 'off', 'no-bitwise': 'off',
'react/no-array-index-key': 'off',
}, },
}; };

View file

@ -12,7 +12,7 @@ import FiltersBlock from './FiltersBlock';
const ScanBlocks = () => ( const ScanBlocks = () => (
<> <>
<ScreenBlock /> <ScreenBlock />
{/* <NavigatorBlock /> */} <NavigatorBlock />
{/* <LocationBlock /> {/* <LocationBlock />
<ConnectionBlock /> */} <ConnectionBlock /> */}
{/* <FingerprintBlock /> {/* <FingerprintBlock />

View file

@ -12,7 +12,7 @@ const TableRow = ({ item }) => {
const [issues, setIssues] = useState(false); const [issues, setIssues] = useState(false);
useEffect(() => { useEffect(() => {
if (item.issues !== '' || workerData !== '') { if (item.issues.filter(Boolean).length !== 0) {
setIssues(true); setIssues(true);
} }
checkWebWorker(item.key, setWorkerData); checkWebWorker(item.key, setWorkerData);
@ -29,10 +29,12 @@ const TableRow = ({ item }) => {
<td>{item.title}</td> <td>{item.title}</td>
<td>{item.value}</td> <td>{item.value}</td>
<td> <td>
{item.issues.map((ele) => ( {item.issues.map((ele, index) => (
<div className="newline">{ele}</div> <div className="newline" key={index}>
{ele}
</div>
))} ))}
{parse(workerData)} <div className="newline">{workerData}</div>
</td> </td>
</tr> </tr>
); );

View file

@ -12,98 +12,154 @@ const getDeviceMemory = () => ({
key: 'deviceMemory', key: 'deviceMemory',
title: 'Device memory', title: 'Device memory',
value: navigator.deviceMemory, value: navigator.deviceMemory,
issues: checkNavigatorProperties('deviceMemory'), issues: [
checkNavigatorProperties('deviceMemory'),
checkNavigatorValue('deviceMemory'),
checkNavigatorPrototype('deviceMemory'),
],
}); });
const getHardwareConcurrency = () => ({ const getHardwareConcurrency = () => ({
key: 'hardwareConcurrency', key: 'hardwareConcurrency',
title: 'Hardware Concurrency', title: 'Hardware Concurrency',
value: navigator.hardwareConcurrency, value: navigator.hardwareConcurrency,
issues: checkNavigatorProperties('hardwareConcurrency'), issues: [
checkNavigatorProperties('hardwareConcurrency'),
checkNavigatorValue('hardwareConcurrency'),
checkNavigatorPrototype('hardwareConcurrency'),
],
}); });
const getMaxTouchPoints = () => ({ const getMaxTouchPoints = () => ({
key: 'maxTouchPoints', key: 'maxTouchPoints',
title: 'Max touchpoints', title: 'Max touchpoints',
value: navigator.maxTouchPoints, value: navigator.maxTouchPoints,
issues: checkNavigatorProperties('maxTouchPoints'), issues: [
checkNavigatorProperties('maxTouchPoints'),
checkNavigatorValue('maxTouchPoints'),
checkNavigatorPrototype('maxTouchPoints'),
],
}); });
const getPlatform = () => ({ const getPlatform = () => ({
key: 'platform', key: 'platform',
title: 'Platform', title: 'Platform',
value: navigator.platform, value: navigator.platform,
issues: checkNavigatorProperties('platform'), issues: [
checkNavigatorProperties('platform'),
checkNavigatorValue('platform'),
checkNavigatorPrototype('platform'),
],
}); });
const getUserAgent = () => ({ const getUserAgent = () => ({
key: 'userAgent', key: 'userAgent',
title: 'User agent', title: 'User agent',
value: navigator.userAgent, value: navigator.userAgent,
issues: checkNavigatorProperties('userAgent'), issues: [
checkNavigatorProperties('userAgent'),
checkNavigatorValue('userAgent'),
checkNavigatorPrototype('userAgent'),
],
}); });
const getLanguage = () => ({ const getLanguage = () => ({
key: 'language', key: 'language',
title: 'Language', title: 'Language',
value: navigator.language, value: navigator.language,
issues: checkNavigatorProperties('language'), issues: [
checkNavigatorProperties('language'),
checkNavigatorValue('language'),
checkNavigatorPrototype('language'),
],
}); });
const getLanguages = () => ({ const getLanguages = () => ({
key: 'languages', key: 'languages',
title: 'Languages', title: 'Languages',
value: navigator.languages, value: navigator.languages,
issues: checkNavigatorProperties('languages'), issues: [
checkNavigatorProperties('languages'),
checkNavigatorValue('languages'),
checkNavigatorPrototype('languages'),
],
}); });
const getCookieEnabled = () => ({ const getCookieEnabled = () => ({
key: 'cookieEnabled', key: 'cookieEnabled',
title: 'Cookies enabled', title: 'Cookies enabled',
value: navigator.cookieEnabled ? 'True' : 'False', value: navigator.cookieEnabled ? 'True' : 'False',
issues: checkNavigatorProperties('cookieEnabled'), issues: [
checkNavigatorProperties('cookieEnabled'),
checkNavigatorValue('cookieEnabled'),
checkNavigatorPrototype('cookieEnabled'),
],
}); });
const getDoNotTrack = () => ({ const getDoNotTrack = () => ({
key: 'doNotTrack', key: 'doNotTrack',
title: 'Do not track header', title: 'Do not track header',
value: navigator.doNotTrack ? 'True' : 'False', value: navigator.doNotTrack ? 'True' : 'False',
issues: checkNavigatorProperties('doNotTrack'), issues: [
checkNavigatorProperties('doNotTrack'),
checkNavigatorValue('doNotTrack'),
checkNavigatorPrototype('doNotTrack'),
],
}); });
const getWebDriver = () => ({ const getWebDriver = () => ({
key: 'webdriver', key: 'webdriver',
title: 'Webdriver', title: 'Webdriver',
value: navigator.webdriver ? 'True' : 'False', value: navigator.webdriver ? 'True' : 'False',
issues: checkNavigatorProperties('webdriver'), issues: [
checkNavigatorProperties('webdriver'),
checkNavigatorValue('webdriver'),
checkNavigatorPrototype('webdriver'),
],
}); });
const getPlugins = () => ({ const getPlugins = () => ({
key: 'plugins', key: 'plugins',
title: 'Plugins', title: 'Plugins',
value: sortPlugins(navigator.plugins), value: sortPlugins(navigator.plugins),
issues: checkNavigatorProperties('plugins'), issues: [
checkNavigatorProperties('plugins'),
checkNavigatorValue('plugins'),
checkNavigatorPrototype('plugins'),
],
}); });
const getVendor = () => ({ const getVendor = () => ({
key: 'vendor', key: 'vendor',
title: 'Vendor', title: 'Vendor',
value: navigator.vendor, value: navigator.vendor,
issues: checkNavigatorProperties('vendor'), issues: [
checkNavigatorProperties('vendor'),
checkNavigatorValue('vendor'),
checkNavigatorPrototype('vendor'),
],
}); });
const getAppVersion = () => ({ const getAppVersion = () => ({
key: 'appVersion', key: 'appVersion',
title: 'App Version', title: 'App Version',
value: navigator.appVersion, value: navigator.appVersion,
issues: checkNavigatorProperties('appVersion'), issues: [
checkNavigatorProperties('appVersion'),
checkNavigatorValue('appVersion'),
checkNavigatorPrototype('appVersion'),
],
}); });
const getProductSub = () => ({ const getProductSub = () => ({
key: 'productSub', key: 'productSub',
title: 'Product sub', title: 'Product sub',
value: navigator.productSub, value: navigator.productSub,
issues: checkNavigatorProperties('productSub'), issues: [
checkNavigatorProperties('productSub'),
checkNavigatorValue('productSub'),
checkNavigatorPrototype('productSub'),
],
}); });
const getWidth = () => ({ const getWidth = () => ({
@ -123,21 +179,30 @@ const getOuterWidth = () => ({
title: 'Outer width', title: 'Outer width',
value: window.outerWidth, value: window.outerWidth,
// issues: checkWindowProperties('outerWidth'), // issues: checkWindowProperties('outerWidth'),
issues: '', issues: [],
}); });
const getAvailWidth = () => ({ const getAvailWidth = () => ({
key: 'availWidth', key: 'availWidth',
title: 'Avail width', title: 'Avail width',
value: window.screen.availWidth, value: window.screen.availWidth,
issues: checkScreenProperties('availWidth') + checkWidth(), issues: [
checkScreenProperties('availWidth'),
checkScreenValue('availWidth'),
checkScreenPrototype('availWidth'),
checkWidth(),
],
}); });
const getHeight = () => ({ const getHeight = () => ({
key: 'height', key: 'height',
title: 'Height', title: 'Height',
value: window.screen.height, value: window.screen.height,
issues: checkScreenProperties('height'), issues: [
checkScreenProperties('height'),
checkScreenValue('height'),
checkScreenPrototype('height'),
],
}); });
const getOuterHeight = () => ({ const getOuterHeight = () => ({
@ -145,28 +210,41 @@ const getOuterHeight = () => ({
title: 'Outer height', title: 'Outer height',
value: window.outerHeight, value: window.outerHeight,
// issues: checkWindowProperties('outerHeight'), // issues: checkWindowProperties('outerHeight'),
issues: '', issues: [],
}); });
const getAvailHeight = () => ({ const getAvailHeight = () => ({
key: 'availHeight', key: 'availHeight',
title: 'Avail height', title: 'Avail height',
value: window.screen.availHeight, value: window.screen.availHeight,
issues: checkScreenProperties('availHeight'), issues: [
checkScreenProperties('availHeight'),
checkScreenValue('availHeight'),
checkScreenPrototype('availHeight'),
checkHeight(),
],
}); });
const getPixelDepth = () => ({ const getPixelDepth = () => ({
key: 'pixelDepth', key: 'pixelDepth',
title: 'Pixel depth', title: 'Pixel depth',
value: window.screen.pixelDepth, value: window.screen.pixelDepth,
issues: checkScreenProperties('pixelDepth'), issues: [
checkScreenProperties('pixelDepth'),
checkScreenValue('pixelDepth'),
checkScreenPrototype('pixelDepth'),
],
}); });
const getColorDepth = () => ({ const getColorDepth = () => ({
key: 'colorDepth', key: 'colorDepth',
title: 'Color depth', title: 'Color depth',
value: window.screen.colorDepth, value: window.screen.colorDepth,
issues: checkScreenProperties('colorDepth'), issues: [
checkScreenProperties('colorDepth'),
checkScreenValue('colorDepth'),
checkScreenPrototype('colorDepth'),
],
}); });
const getNavigator = () => [ const getNavigator = () => [
@ -188,13 +266,13 @@ const getNavigator = () => [
const getScreen = () => [ const getScreen = () => [
getWidth(), getWidth(),
// getAvailWidth(), getAvailWidth(),
// getOuterWidth(), getOuterWidth(),
// getHeight(), getHeight(),
// getAvailHeight(), getAvailHeight(),
// getOuterHeight(), getOuterHeight(),
// getPixelDepth(), getPixelDepth(),
// getColorDepth(), getColorDepth(),
]; ];
// sorts plugins object into comma separated list // sorts plugins object into comma separated list
@ -210,49 +288,34 @@ const sortPlugins = (data) => {
}; };
const checkNavigatorProperties = (key) => { const checkNavigatorProperties = (key) => {
const list = [];
if (Object.getOwnPropertyDescriptor(navigator, key) !== undefined) { if (Object.getOwnPropertyDescriptor(navigator, key) !== undefined) {
list.push('Failed undefined properties'); return 'Failed undefined properties';
} }
return null;
};
const checkNavigatorValue = (key) => {
if ( if (
Object.getOwnPropertyDescriptor(Navigator.prototype, key).value !== Object.getOwnPropertyDescriptor(Navigator.prototype, key).value !==
undefined undefined
) { ) {
list.push('Failed descriptor.value undefined'); return 'Failed descriptor.value undefined';
} }
return null;
};
const checkNavigatorPrototype = (key) => {
try { try {
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
const check = Navigator.prototype[key]; const check = Navigator.prototype[key];
list.push('Failed Navigator.prototype'); return 'Failed Navigator.prototype';
} catch (err) { } catch (err) {
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
const check = ''; const check = '';
} }
return list.toString().split(',').join('<br />'); return null;
}; };
// const checkScreenProperties = (key) => {
// const list = [];
// if (Object.getOwnPropertyDescriptor(window.screen, key) !== undefined) {
// list.push('Failed undefined properties');
// }
// if (
// Object.getOwnPropertyDescriptor(Screen.prototype, key).value !== undefined
// ) {
// list.push('Failed descriptor.value undefined');
// }
// try {
// // eslint-disable-next-line no-unused-vars
// const check = Screen.prototype[key];
// list.push('Failed Navigator.prototype');
// } catch (err) {
// // eslint-disable-next-line no-unused-vars
// const check = '';
// }
// return list.toString().split(',').join('<br />');
// };
const checkScreenProperties = (key) => { const checkScreenProperties = (key) => {
if (Object.getOwnPropertyDescriptor(window.screen, key) !== undefined) { if (Object.getOwnPropertyDescriptor(window.screen, key) !== undefined) {
return 'Failed undefined properties'; return 'Failed undefined properties';
@ -304,7 +367,14 @@ const checkWidth = () => {
if (window.screen.availWidth > window.screen.width) { if (window.screen.availWidth > window.screen.width) {
return 'Avail width is wider then width'; return 'Avail width is wider then width';
} }
return ''; return null;
};
const checkHeight = () => {
if (window.screen.availHeight > window.screen.height) {
return 'Avail height is wider then height';
}
return null;
}; };
const checkWebWorker = (key, setWorkerData) => { const checkWebWorker = (key, setWorkerData) => {
@ -318,9 +388,7 @@ const checkWebWorker = (key, setWorkerData) => {
event.data !== undefined && event.data !== undefined &&
event.data.toString() !== navigator[key].toString() event.data.toString() !== navigator[key].toString()
) { ) {
setWorkerData( setWorkerData(`Did not match web worker (${event.data.toString()})`);
`<br />Did not match web worker (${event.data.toString()})`
);
} }
}; };
}; };