Detect adblock
This commit is contained in:
parent
80cd80d493
commit
43555f5466
2 changed files with 54 additions and 30 deletions
|
|
@ -1,3 +1,4 @@
|
||||||
|
/* 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 Bowser from 'bowser';
|
||||||
|
|
@ -7,30 +8,47 @@ import {
|
||||||
checkNavigatorProperties,
|
checkNavigatorProperties,
|
||||||
checkWebWorker,
|
checkWebWorker,
|
||||||
checkScreenProperties,
|
checkScreenProperties,
|
||||||
getOther,
|
detectTor,
|
||||||
} from './main';
|
} from './main';
|
||||||
|
|
||||||
const OtherBlock = () => {
|
const OtherBlock = () => {
|
||||||
const [firstRender, setfirstRender] = useState(true);
|
const [adBlockDetected, setAdBlockDetected] = useState(false);
|
||||||
const [workerData, setWorkerData] = useState('');
|
|
||||||
const [userAgent, setUserAgent] = useState();
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
checkWebWorker('userAgent', setWorkerData);
|
fetch('https://www3.doubleclick.net', {
|
||||||
|
method: 'HEAD',
|
||||||
|
mode: 'no-cors',
|
||||||
|
cache: 'no-store',
|
||||||
|
}).catch(() => {
|
||||||
|
setAdBlockDetected(true);
|
||||||
|
});
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (!workerData) {
|
|
||||||
setUserAgent(Bowser.parse(navigator.userAgent));
|
|
||||||
} else {
|
|
||||||
setUserAgent(Bowser.parse(workerData));
|
|
||||||
}
|
|
||||||
}, [workerData]);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ScanBlock>
|
<ScanBlock>
|
||||||
<h1>Other</h1>
|
<h1>Other</h1>
|
||||||
<Table type="screen" data={getOther()} />
|
<div className="tableWrap">
|
||||||
|
<table>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td>Brave browser</td>
|
||||||
|
<td>{navigator.brave ? 'True' : 'False'}</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td>Tor Browser</td>
|
||||||
|
<td>{detectTor() ? 'True' : 'False'}</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td>Adblock</td>
|
||||||
|
<td>{adBlockDetected ? 'True' : 'False'}</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
<p>
|
<p>
|
||||||
<b>Explanation:</b> JavaScript can be used to find information about
|
<b>Explanation:</b> JavaScript can be used to find information about
|
||||||
your hardware. This information can be used to create a fingerprint.
|
your hardware. This information can be used to create a fingerprint.
|
||||||
|
|
@ -38,5 +56,4 @@ const OtherBlock = () => {
|
||||||
</ScanBlock>
|
</ScanBlock>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default OtherBlock;
|
export default OtherBlock;
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ export {
|
||||||
checkWebWorker,
|
checkWebWorker,
|
||||||
getScreen,
|
getScreen,
|
||||||
checkScreenProperties,
|
checkScreenProperties,
|
||||||
getOther,
|
detectTor,
|
||||||
};
|
};
|
||||||
|
|
||||||
const getDeviceMemory = () => ({
|
const getDeviceMemory = () => ({
|
||||||
|
|
@ -278,13 +278,6 @@ const getScreen = () => [
|
||||||
getColorDepth(),
|
getColorDepth(),
|
||||||
];
|
];
|
||||||
|
|
||||||
const getBrave = () => ({
|
|
||||||
key: 'brave',
|
|
||||||
title: 'Brave browser',
|
|
||||||
value: navigator.brave ? 'True' : 'False',
|
|
||||||
issues: [],
|
|
||||||
});
|
|
||||||
|
|
||||||
const detectTor = () => {
|
const detectTor = () => {
|
||||||
const date = new Date();
|
const date = new Date();
|
||||||
if (
|
if (
|
||||||
|
|
@ -298,14 +291,28 @@ const detectTor = () => {
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
const getTor = () => ({
|
// const getTor = () => ({
|
||||||
key: 'tor',
|
// key: 'tor',
|
||||||
title: 'Tor browser',
|
// title: 'Tor browser',
|
||||||
value: detectTor() ? 'True' : 'False',
|
// value: detectTor() ? 'True' : 'False',
|
||||||
issues: [],
|
// issues: [],
|
||||||
});
|
// });
|
||||||
|
|
||||||
const getOther = () => [getBrave(), getTor()];
|
// const getAdblock = () => ({
|
||||||
|
// key: 'adblock',
|
||||||
|
// title: 'Adblock',
|
||||||
|
// value: Promise.resolve(detectAdblock()),
|
||||||
|
// issues: [],
|
||||||
|
// });
|
||||||
|
|
||||||
|
// const detectAdblock = () =>
|
||||||
|
// fetch('https://www3.doubleclick.net', {
|
||||||
|
// method: 'HEAD',
|
||||||
|
// mode: 'no-cors',
|
||||||
|
// cache: 'no-store',
|
||||||
|
// });
|
||||||
|
|
||||||
|
// const getOther = () => [getBrave(), getTor(), getAdblock()];
|
||||||
|
|
||||||
// sorts plugins object into comma separated list
|
// sorts plugins object into comma separated list
|
||||||
const sortPlugins = (data) => {
|
const sortPlugins = (data) => {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue