-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
36 lines (31 loc) · 895 Bytes
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>AdBlock Checker</title>
</head>
<body>
<div id="result"></div>
<script>
function init() {
adsBlocked().then(adsAreBeingBlocked => {
const msg = { adsAreBeingBlocked };
document.getElementById('result').innerText = JSON.stringify(msg);
console.log(msg);
});
}
function adsBlocked() {
const testURL ='https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js';
const reqOpt = {
method: 'HEAD',
mode: 'no-cors'
};
const testReq = new Request(testURL, reqOpt);
return fetch(testReq)
.then(res => { return false })
.catch(err =>{ return true })
}
document.addEventListener("DOMContentLoaded", init());
</script>
</body>
</html>