Fixed battery errors on firefox
This commit is contained in:
parent
680d416ce0
commit
f33c3686ba
3 changed files with 66 additions and 49 deletions
|
|
@ -20,9 +20,13 @@ const OtherBlock = ({ workerData }) => {
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
setAdBlock(true);
|
setAdBlock(true);
|
||||||
});
|
});
|
||||||
navigator.getBattery().then((res) => {
|
if ('getBattery' in navigator) {
|
||||||
setBattery(res);
|
navigator.getBattery().then((res) => {
|
||||||
});
|
setBattery(res);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
setBattery('N/A');
|
||||||
|
}
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
||||||
|
|
@ -157,11 +157,11 @@ const checkNavigatorProperties = (key) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const checkNavigatorValue = (key) => {
|
const checkNavigatorValue = (key) => {
|
||||||
if (
|
try {
|
||||||
Object.getOwnPropertyDescriptor(Navigator.prototype, key).value !==
|
// eslint-disable-next-line no-unused-vars
|
||||||
undefined
|
const { value } = Object.getOwnPropertyDescriptor(Navigator.prototype, key);
|
||||||
) {
|
} catch (err) {
|
||||||
return 'Failed descriptor.value undefined';
|
return 'Failed Navigator.prototype';
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -21,45 +21,58 @@ const checkDatePrototype = () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
// Returns object with location data
|
// Returns object with location data
|
||||||
const getOther = (battery, adBlock, workerData) => [
|
const getOther = (battery, adBlock, workerData) => {
|
||||||
{
|
console.log(battery);
|
||||||
key: 'Brave browser',
|
let batteryLevel, batteryStatus;
|
||||||
value: navigator.brave ? 'True' : 'False',
|
if (battery === 'N/A') {
|
||||||
issues: [],
|
batteryLevel = 'N/A';
|
||||||
},
|
batteryStatus = 'N/A';
|
||||||
{
|
} else {
|
||||||
key: 'Tor browser',
|
batteryLevel = `${Math.round(battery.level * 100)}%`;
|
||||||
value: detectTor() ? 'True' : 'False',
|
batteryStatus = battery.charging ? 'Charging' : 'Not charging';
|
||||||
issues: [],
|
}
|
||||||
},
|
return [
|
||||||
{
|
{
|
||||||
key: 'Adblock',
|
key: 'Brave browser',
|
||||||
value: adBlock ? 'True' : 'False',
|
value: navigator.brave ? 'True' : 'False',
|
||||||
issues: [],
|
issues: [],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: 'Date',
|
key: 'Tor browser',
|
||||||
value: new Date().toString(),
|
value: detectTor() ? 'True' : 'False',
|
||||||
issues: [checkDatePrototype()],
|
issues: [],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: 'Timezone offset',
|
key: 'Adblock',
|
||||||
value: new Date().getTimezoneOffset(),
|
value: adBlock ? 'True' : 'False',
|
||||||
issues: [
|
issues: [],
|
||||||
checkDatePrototype(),
|
},
|
||||||
checkWebWorker(new Date().getTimezoneOffset(), workerData.timezoneOffset),
|
{
|
||||||
],
|
key: 'Date',
|
||||||
},
|
value: new Date().toString(),
|
||||||
{
|
issues: [checkDatePrototype()],
|
||||||
key: 'Battery level',
|
},
|
||||||
value: `${Math.round(battery.level * 100)}%`,
|
{
|
||||||
issues: [],
|
key: 'Timezone offset',
|
||||||
},
|
value: new Date().getTimezoneOffset(),
|
||||||
{
|
issues: [
|
||||||
key: 'Battery status',
|
checkDatePrototype(),
|
||||||
value: battery.charging ? 'Charging' : 'Not charging',
|
checkWebWorker(
|
||||||
issues: [],
|
new Date().getTimezoneOffset(),
|
||||||
},
|
workerData.timezoneOffset
|
||||||
];
|
),
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'Battery level',
|
||||||
|
value: batteryLevel,
|
||||||
|
issues: [],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'Battery status',
|
||||||
|
value: batteryStatus,
|
||||||
|
issues: [],
|
||||||
|
},
|
||||||
|
];
|
||||||
|
};
|
||||||
export default getOther;
|
export default getOther;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue