This content originally appeared on DEV Community and was authored by sagarjaid
// This is react example.
import { useEffect } from 'react';
const hello = () => {
useEffect(() => {
const timeoutId = setTimeout(() => {
const adBoxEl = document.querySelector(".ad-box");
const hasAdBlock = window.getComputedStyle(adBoxEl)?.display === "none";
console.log(hasAdBlock, "hasAdBlock");
// ... save to DB
}, 1000);
return () => clearTimeout(timeoutId);
}, []);
return (
<div className="ad-box" style={{ position: "fixed", top: 0, left: 0 }} aria-hidden="true">
</div>
);
}
export default hello
This content originally appeared on DEV Community and was authored by sagarjaid
Print
Share
Comment
Cite
Upload
Translate
Updates
There are no updates yet.
Click the Upload button above to add an update.
APA
MLA
sagarjaid | Sciencx (2023-05-07T21:31:48+00:00) Detect any AdBlocker with Javascript code.. Retrieved from https://www.scien.cx/2023/05/07/detect-any-adblocker-with-javascript-code/
" » Detect any AdBlocker with Javascript code.." sagarjaid | Sciencx - Sunday May 7, 2023, https://www.scien.cx/2023/05/07/detect-any-adblocker-with-javascript-code/
HARVARDsagarjaid | Sciencx Sunday May 7, 2023 » Detect any AdBlocker with Javascript code.., viewed ,<https://www.scien.cx/2023/05/07/detect-any-adblocker-with-javascript-code/>
VANCOUVERsagarjaid | Sciencx - » Detect any AdBlocker with Javascript code.. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2023/05/07/detect-any-adblocker-with-javascript-code/
CHICAGO" » Detect any AdBlocker with Javascript code.." sagarjaid | Sciencx - Accessed . https://www.scien.cx/2023/05/07/detect-any-adblocker-with-javascript-code/
IEEE" » Detect any AdBlocker with Javascript code.." sagarjaid | Sciencx [Online]. Available: https://www.scien.cx/2023/05/07/detect-any-adblocker-with-javascript-code/. [Accessed: ]
rf:citation » Detect any AdBlocker with Javascript code. | sagarjaid | Sciencx | https://www.scien.cx/2023/05/07/detect-any-adblocker-with-javascript-code/ |
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.