-
Notifications
You must be signed in to change notification settings - Fork 254
/
test.html
249 lines (232 loc) · 8.43 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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
<!doctype html>
<html>
<head>
<title>FuckAdBlock 3.2.1</title>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
<link href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/default.min.css" rel="stylesheet">
<link href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/atom-one-light.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;
}
code,
.pre-inline {
font-family: Consolas, "Courier New", monospace !important;
}
pre {
background-color: #fafafa;
}
.pre-inline {
padding: 1px 2px;
font-size: 13px;
border: 1px solid #ccc;
border-radius: 4px;
background-color: #fafafa;
}
</style>
</head>
<body>
<div class="container">
<header class="row">
<div class="col-sm-6">
<h1>FuckAdBlock <small>3.2.1</small></h1>
</div>
<div class="col-sm-6 text-right">
<h4>
<a href="https://github.com/sitexw/BlockAdBlock" style="color: #acc6d7;">BlockAdBlock</a>
<a href="https://sitexw.fr/fuckadblock/">Online example</a>
<a href="https://github.com/sitexw/FuckAdBlock">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</h3>
<h5 class="bg-success" id="fab-not-enabled" style="display: none;">AdBlock is not enabled</h5>
<h5 class="bg-danger" id="fab-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">Install via</h3>
<p>NPM:</p>
<pre>npm install fuckadblock</pre>
<p>Bower:</p>
<pre>bower install fuckadblock</pre>
<p>CDN:</p>
<pre>https://cdnjs.cloudflare.com/ajax/libs/fuckadblock/3.2.1/fuckadblock.min.js
https://cdn.jsdelivr.net/npm/[email protected]/fuckadblock.min.js</pre>
<p>Integrity:</p>
<pre>sha256-4/8cdZfUJoNm8DLRzuKwvhusQbdUqVov+6bVj9ewL7U= (fuckadblock.js)
sha256-xjwKUY/NgkPjZZBOtOxRYtK20GaqTwUCf7WYCJ1z69w= (fuckadblock.min.js)</pre>
<h3 class="text-left">Code example</h3>
<p>Ideally positioned at the end of <span class="pre-inline"><body></span>.</p>
<pre><code class="javascript">// 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');
}
// We look at whether FuckAdBlock already exists.
if(typeof fuckAdBlock !== 'undefined' || typeof FuckAdBlock !== 'undefined') {
// If this is the case, it means that something tries to usurp are identity
// So, considering that it is a detection
adBlockDetected();
} else {
// Otherwise, you import the script FuckAdBlock
var importFAB = document.createElement('script');
importFAB.onload = function() {
// If all goes well, we configure FuckAdBlock
fuckAdBlock.onDetected(adBlockDetected)
fuckAdBlock.onNotDetected(adBlockNotDetected);
};
importFAB.onerror = function() {
// If the script does not load (blocked, integrity error, ...)
// Then a detection is triggered
adBlockDetected();
};
importFAB.integrity = 'sha256-xjwKUY/NgkPjZZBOtOxRYtK20GaqTwUCf7WYCJ1z69w=';
importFAB.crossOrigin = 'anonymous';
importFAB.src = 'https://cdnjs.cloudflare.com/ajax/libs/fuckadblock/3.2.1/fuckadblock.min.js';
document.head.appendChild(importFAB);
}</code></pre>
<h3 class="text-left">Default options</h3>
<pre><code class="javascript">// 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;'
// Displays the debug in the console (available only from version 3.2 and more)
debug: false
</code></pre>
<h3 class="text-left">Method available</h3>
<pre><code class="javascript">// 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);</code></pre>
<h3 class="text-left">Instance</h3>
<p>
<i>(Available only from version 3.1 and more)</i><br>
By default, FuckAdBlock is instantiated automatically.<br>
To block this automatic instantiation, simply create a variable "fuckAdBlock" with a value (null, false, ...) before importing the script.
</p>
<pre><code class="html"><script>var fuckAdBlock = false;</script>
<script src="./fuckadblock.js"></script></code></pre>
After that, you are free to create your own instances:
<pre><code class="javascript">fuckAdBlock = new FuckAdBlock;
// and|or
myFuckAdBlock = new FuckAdBlock({
checkOnLoad: true,
resetOnEnd: true
});</code></pre>
</div>
</div>
</div>
<script>
// Function called if AdBlock is not detected
function adBlockNotDetected() {
document.querySelector('#fab-enabled').style.display = 'none';
document.querySelector('#fab-not-enabled').style.display = 'block';
}
// Function called if AdBlock is detected
function adBlockDetected() {
document.querySelector('#fab-enabled').style.display = 'block';
document.querySelector('#fab-not-enabled').style.display = 'none';
}
// We look at whether FuckAdBlock already exists.
if(typeof fuckAdBlock !== 'undefined' || typeof FuckAdBlock !== 'undefined') {
// If this is the case, it means that something tries to usurp are identity
// So, considering that it is a detection
adBlockDetected();
} else {
// Otherwise, you import the script FuckAdBlock
var importFAB = document.createElement('script');
importFAB.onload = function() {
// If all goes well, we configure FuckAdBlock
fuckAdBlock.onDetected(adBlockDetected)
fuckAdBlock.onNotDetected(adBlockNotDetected);
};
importFAB.onerror = function() {
// If the script does not load (integrity problem, ...)
// Then a detection is triggered
adBlockDetected();
};
importFAB.integrity = 'sha256-4/8cdZfUJoNm8DLRzuKwvhusQbdUqVov+6bVj9ewL7U=';
importFAB.crossOrigin = 'anonymous';
importFAB.src = 'https://cdnjs.cloudflare.com/ajax/libs/fuckadblock/3.2.1/fuckadblock.js';
document.head.appendChild(importFAB);
}
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min.js"></script>
<script>
document.querySelectorAll('pre code').forEach(function(element) {
hljs.highlightBlock(element);
});
</script>
</body>
</html>