-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadblock.js
More file actions
30 lines (27 loc) · 741 Bytes
/
adblock.js
File metadata and controls
30 lines (27 loc) · 741 Bytes
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
// checking adblock
function checkAdsBlocked(callback) {
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function () {
if (xhr.readyState == XMLHttpRequest.DONE) {
callback(xhr.status === 0 || xhr.responseURL !== ADS_URL);
}
};
xhr.open('HEAD', ADS_URL, true);
xhr.send(null);
}
function getCookie(cname) {
let name = cname + "=";
let decodedCookie = decodeURIComponent(document.cookie);
let ca = decodedCookie.split(';');
for(let i = 0; i <ca.length; i++) {
let c = ca[i];
while (c.charAt(0) == ' ') {
c = c.substring(1);
}
if (c.indexOf(name) == 0) {
return c.substring(name.length, c.length);
}
}
return "";
}
// end checking adblock