Added battery api to other block
This commit is contained in:
parent
43555f5466
commit
fa69e2ec34
1 changed files with 20 additions and 8 deletions
|
|
@ -1,18 +1,13 @@
|
||||||
/* eslint-disable arrow-body-style */
|
/* eslint-disable arrow-body-style */
|
||||||
/* eslint-disable no-unused-vars */
|
/* eslint-disable no-unused-vars */
|
||||||
import { useState, useEffect } from 'react';
|
import { useState, useEffect } from 'react';
|
||||||
import Bowser from 'bowser';
|
|
||||||
import ScanBlock from './ScanBlock';
|
import ScanBlock from './ScanBlock';
|
||||||
import Table from './Table';
|
import { detectTor } from './main';
|
||||||
import {
|
|
||||||
checkNavigatorProperties,
|
|
||||||
checkWebWorker,
|
|
||||||
checkScreenProperties,
|
|
||||||
detectTor,
|
|
||||||
} from './main';
|
|
||||||
|
|
||||||
const OtherBlock = () => {
|
const OtherBlock = () => {
|
||||||
const [adBlockDetected, setAdBlockDetected] = useState(false);
|
const [adBlockDetected, setAdBlockDetected] = useState(false);
|
||||||
|
const [batteryLevel, setBatteryLevel] = useState();
|
||||||
|
const [batteryStatus, setBatteryStatus] = useState();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
fetch('https://www3.doubleclick.net', {
|
fetch('https://www3.doubleclick.net', {
|
||||||
|
|
@ -22,6 +17,11 @@ const OtherBlock = () => {
|
||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
setAdBlockDetected(true);
|
setAdBlockDetected(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
navigator.getBattery().then((res) => {
|
||||||
|
setBatteryLevel(`${Math.round(res.level * 100)}%`);
|
||||||
|
setBatteryStatus(res.charging ? 'Charging' : 'Not charging');
|
||||||
|
});
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
@ -47,6 +47,18 @@ const OtherBlock = () => {
|
||||||
<td>{adBlockDetected ? 'True' : 'False'}</td>
|
<td>{adBlockDetected ? 'True' : 'False'}</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td>Battery level</td>
|
||||||
|
<td>{batteryLevel}</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td>Battery status</td>
|
||||||
|
<td>{batteryStatus}</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
<p>
|
<p>
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue