forked from veeracs/SniffAdBlock
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.html
180 lines (164 loc) · 5.28 KB
/
test.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
<!doctype html>
<html>
<head>
<title>FuckAdBlock 3.0.2</title>
<link href="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet">
<style>
header {
margin-bottom: 20px;
}
.outline {
width: 302px;
height: 252px;
border: 1px solid #cccccc;
border-radius: 4px;
background-color: #f2dede;
}
.pub_300x250 {
width: 300px;
height: 250px;
background-color: #dff0d8;
}
h5.bg-success,
h5.bg-danger {
padding: 8px;
border: 1px solid #cccccc;
border-radius: 4px;
}
</style>
</head>
<body>
<div class="container">
<header class="row">
<div class="col-sm-8">
<h1>FuckAdBlock <small>3.0.2</small></h1>
</div>
<div class="col-sm-4 text-right">
<h4>
<a href="http://sitexw.fr/fuckadblock/" target="_blank">Online example</a>
<a href="https://github.com/sitexw/FuckAdBlock" target="_blank">GitHub</a>
</h4>
</div>
</header>
<div class="row">
<div class="col-sm-5">
<div class="outline">
<div class="pub_300x250"></div>
</div>
</div>
<div class="col-sm-7">
<h3 class="text-left">Publicity example<button class="btn btn-primary btn-xs pull-right" onclick="checkAgain();">Check again</button></h3>
<h5 class="bg-success" id="adb-not-enabled" style="display: none;">AdBlock is not enabled</h5>
<h5 class="bg-danger" id="adb-enabled" style="display: none;">AdBlock is enabled</h5>
</div>
</div>
<div class="row">
<div class="col-sm-12">
<h3 class="text-left">Valid on :</h3>
<ul>
<li>Google Chrome</li>
<li>Mozilla Firefox</li>
<li>Internet Explorer (8+)</li>
<li>Safari</li>
<li>Opera</li>
</ul>
<h3 class="text-left">Code example</h3>
<pre>// Function called if AdBlock is not detected
function adBlockNotDetected() {
alert('AdBlock is not enabled');
}
// Function called if AdBlock is detected
function adBlockDetected() {
alert('AdBlock is enabled');
}
// Recommended audit because AdBlock lock the file 'fuckadblock.js'
// If the file is not called, the variable does not exist 'fuckAdBlock'
// This means that AdBlock is present
if(typeof fuckAdBlock === 'undefined') {
adBlockDetected();
} else {
fuckAdBlock.onDetected(adBlockDetected);
fuckAdBlock.onNotDetected(adBlockNotDetected);
// and|or
fuckAdBlock.on(true, adBlockDetected);
fuckAdBlock.on(false, adBlockNotDetected);
// and|or
fuckAdBlock.on(true, adBlockDetected).onNotDetected(adBlockNotDetected);
}
// Change the options
fuckAdBlock.setOptions('checkOnLoad', false);
// and|or
fuckAdBlock.setOptions({
checkOnLoad: false,
resetOnEnd: false
});</pre>
<h3 class="text-left">Default options</h3>
<pre>// At launch, check if AdBlock is enabled
// Uses the method fuckAdBlock.check()
checkOnLoad: true
// At the end of the check, is that it removes all events added ?
resetOnEnd: true
// The number of milliseconds between each check
loopCheckTime: 50
// The number of negative checks after which there is considered that AdBlock is not enabled
// Time (ms) = 50*(5-1) = 200ms (per default)
loopMaxNumber: 5
// CSS class used by the bait caught AdBlock
baitClass: 'pub_300x250 pub_300x250m pub_728x90 text-ad textAd text_ad text_ads text-ads text-ad-links'
// CSS style used to hide the bait of the users
baitStyle: 'width: 1px !important; height: 1px !important; position: absolute !important; left: -10000px !important; top: -1000px !important;'
</pre>
<h3 class="text-left">Method available</h3>
<pre>// Allows to set options
// #options: string|object
// #value: string
fuckAdBlock.setOption(options, value);
// Allows to check if AdBlock is enabled
// The parameter 'loop' allows checking without loop several times according to the value of 'loopMaxNumber'
// Example: loop=true => time~=200ms (time varies depending on the configuration)
// loop=false => time~=1ms
// #loop: boolean (default: true)
fuckAdBlock.check(loop);
// Allows to manually simulate the presence of AdBlock or not
// #detected: boolean (AdBlock is detected ?)
fuckAdBlock.emitEvent(detected);
// Allows to clear all events added via methods 'on', 'onDetected' and 'onNotDetected'
fuckAdBlock.clearEvent();
// Allows to add an event if AdBlock is detected
// #detected: boolean (true: detected, false: not detected)
// #fn: function
fuckAdBlock.on(detected, fn);
// Similar to fuckAdBlock.on(true|false, fn)
fuckAdBlock.onDetected(fn);
fuckAdBlock.onNotDetected(fn);
</pre>
</div>
</div>
</div>
<script src="./fuckadblock.js"></script>
<script>
function adBlockDetected() {
document.getElementById('adb-enabled').style.display = 'block';
document.getElementById('adb-not-enabled').style.display = 'none';
}
function adBlockNotDetected() {
document.getElementById('adb-enabled').style.display = 'none';
document.getElementById('adb-not-enabled').style.display = 'block';
}
if(typeof fuckAdBlock === 'undefined') {
adBlockDetected();
} else {
fuckAdBlock.onDetected(adBlockDetected).onNotDetected(adBlockNotDetected);
}
function checkAgain() {
document.getElementById('adb-enabled').style.display = 'none';
document.getElementById('adb-not-enabled').style.display = 'none';
fuckAdBlock.onDetected(adBlockDetected).onNotDetected(adBlockNotDetected);
setTimeout(function() {
fuckAdBlock.check();
}, 500);
}
</script>
</body>
</html>