vendor: 7,171 bytes, lines 1-250
1/* 2 * FuckAdBlock 3.2.1 3 * Copyright (c) 2015 Valentin Allaire <[email protected]> 4 * Released under the MIT license 5 * https://github.com/sitexw/FuckAdBlock 6 */ 7 8(function(window) { 9 var FuckAdBlock = function(options) { 10 this._options = { 11 checkOnLoad: false, 12 resetOnEnd: false, 13 loopCheckTime: 50, 14 loopMaxNumber: 5, 15 baitClass: 'pub_300x250 pub_300x250m pub_728x90 text-ad textAd text_ad text_ads text-ads text-ad-links', 16 baitStyle: 'width: 1px !important; height: 1px !important; position: absolute !important; left: -10000px !important; top: -1000px !important;', 17 debug: false 18 }; 19 this._var = { 20 version: '3.2.1', 21 bait: null, 22 checking: false, 23 loop: null, 24 loopNumber: 0, 25 event: { detected: [], notDetected: [] } 26 }; 27 if(options !== undefined) { 28 this.setOption(options); 29 } 30 var self = this; 31 var eventCallback = function() { 32 setTimeout(function() { 33 if(self._options.checkOnLoad === true) { 34 if(self._options.debug === true) { 35 self._log('onload->eventCallback', 'A check loading is launched'); 36 } 37 if(self._var.bait === null) { 38 self._creatBait(); 39 } 40 setTimeout(function() { 41 self.check(); 42 }, 1); 43 } 44 }, 1); 45 }; 46 if(window.addEventListener !== undefined) { 47 window.addEventListener('load', eventCallback, false); 48 } else { 49 window.attachEvent('onload', eventCallback); 50 } 51 }; 52 FuckAdBlock.prototype._options = null; 53 FuckAdBlock.prototype._var = null; 54 FuckAdBlock.prototype._bait = null; 55 56 FuckAdBlock.prototype._log = function(method, message) { 57 console.log('[FuckAdBlock]['+method+'] '+message); 58 }; 59 60 FuckAdBlock.prototype.setOption = function(options, value) { 61 if(value !== undefined) { 62 var key = options; 63 options = {}; 64 options[key] = value; 65 } 66 for(var option in options) { 67 this._options[option] = options[option]; 68 if(this._options.debug === true) { 69 this._log('setOption', 'The option "'+option+'" he was assigned to "'+options[option]+'"'); 70 } 71 } 72 return this; 73 }; 74 75 FuckAdBlock.prototype._creatBait = function() { 76 var bait = document.createElement('div'); 77 bait.setAttribute('class', this._options.baitClass); 78 bait.setAttribute('style', this._options.baitStyle); 79 this._var.bait = window.document.body.appendChild(bait); 80 81 this._var.bait.offsetParent; 82 this._var.bait.offsetHeight; 83 this._var.bait.offsetLeft; 84 this._var.bait.offsetTop; 85 this._var.bait.offsetWidth; 86 this._var.bait.clientHeight; 87 this._var.bait.clientWidth; 88 89 if(this._options.debug === true) { 90 this._log('_creatBait', 'Bait has been created'); 91 } 92 }; 93 FuckAdBlock.prototype._destroyBait = function() { 94 window.document.body.removeChild(this._var.bait); 95 this._var.bait = null; 96 97 if(this._options.debug === true) { 98 this._log('_destroyBait', 'Bait has been removed'); 99 } 100 }; 101 102 FuckAdBlock.prototype.check = function(loop) { 103 if(loop === undefined) { 104 loop = true; 105 } 106 107 if(this._options.debug === true) { 108 this._log('check', 'An audit was requested '+(loop===true?'with a':'without')+' loop'); 109 } 110 111 if(this._var.checking === true) { 112 if(this._options.debug === true) { 113 this._log('check', 'A check was canceled because there is already an ongoing'); 114 } 115 return false; 116 } 117 this._var.checking = true; 118 119 if(this._var.bait === null) { 120 this._creatBait(); 121 } 122 123 var self = this; 124 this._var.loopNumber = 0; 125 if(loop === true) { 126 this._var.loop = setInterval(function() { 127 self._checkBait(loop); 128 }, this._options.loopCheckTime); 129 } 130 setTimeout(function() { 131 self._checkBait(loop); 132 }, 1); 133 if(this._options.debug === true) { 134 this._log('check', 'A check is in progress ...'); 135 } 136 137 return true; 138 }; 139 FuckAdBlock.prototype._checkBait = function(loop) { 140 var detected = false; 141 142 if(this._var.bait === null) { 143 this._creatBait(); 144 } 145 146 if(window.document.body.getAttribute('abp') !== null 147 || this._var.bait.offsetParent === null 148 || this._var.bait.offsetHeight == 0 149 || this._var.bait.offsetLeft == 0 150 || this._var.bait.offsetTop == 0 151 || this._var.bait.offsetWidth == 0 152 || this._var.bait.clientHeight == 0 153 || this._var.bait.clientWidth == 0) { 154 detected = true; 155 } 156 if(window.getComputedStyle !== undefined) { 157 var baitTemp = window.getComputedStyle(this._var.bait, null); 158 if(baitTemp && (baitTemp.getPropertyValue('display') == 'none' || baitTemp.getPropertyValue('visibility') == 'hidden')) { 159 detected = true; 160 } 161 } 162 163 if(this._options.debug === true) { 164 this._log('_checkBait', 'A check ('+(this._var.loopNumber+1)+'/'+this._options.loopMaxNumber+' ~'+(1+this._var.loopNumber*this._options.loopCheckTime)+'ms) was conducted and detection is '+(detected===true?'positive':'negative')); 165 } 166 167 if(loop === true) { 168 this._var.loopNumber++; 169 if(this._var.loopNumber >= this._options.loopMaxNumber) { 170 this._stopLoop(); 171 } 172 } 173 174 if(detected === true) { 175 this._stopLoop(); 176 this._destroyBait(); 177 this.emitEvent(true); 178 if(loop === true) { 179 this._var.checking = false; 180 } 181 } else if(this._var.loop === null || loop === false) { 182 this._destroyBait(); 183 this.emitEvent(false); 184 if(loop === true) { 185 this._var.checking = false; 186 } 187 } 188 }; 189 FuckAdBlock.prototype._stopLoop = function(detected) { 190 clearInterval(this._var.loop); 191 this._var.loop = null; 192 this._var.loopNumber = 0; 193 194 if(this._options.debug === true) { 195 this._log('_stopLoop', 'A loop has been stopped'); 196 } 197 }; 198 199 FuckAdBlock.prototype.emitEvent = function(detected) { 200 if(this._options.debug === true) { 201 this._log('emitEvent', 'An event with a '+(detected===true?'positive':'negative')+' detection was called'); 202 } 203 204 var fns = this._var.event[(detected===true?'detected':'notDetected')]; 205 for(var i in fns) { 206 if(this._options.debug === true) { 207 this._log('emitEvent', 'Call function '+(parseInt(i)+1)+'/'+fns.length); 208 } 209 if(fns.hasOwnProperty(i)) { 210 fns[i](); 211 } 212 } 213 if(this._options.resetOnEnd === true) { 214 this.clearEvent(); 215 } 216 return this; 217 }; 218 FuckAdBlock.prototype.clearEvent = function() { 219 this._var.event.detected = []; 220 this._var.event.notDetected = []; 221 222 if(this._options.debug === true) { 223 this._log('clearEvent', 'The event list has been cleared'); 224 } 225 }; 226 227 FuckAdBlock.prototype.on = function(detected, fn) { 228 this._var.event[(detected===true?'detected':'notDetected')].push(fn); 229 if(this._options.debug === true) { 230 this._log('on', 'A type of event "'+(detected===true?'detected':'notDetected')+'" was added'); 231 } 232 233 return this; 234 }; 235 FuckAdBlock.prototype.onDetected = function(fn) { 236 return this.on(true, fn); 237 }; 238 FuckAdBlock.prototype.onNotDetected = function(fn) { 239 return this.on(false, fn); 240 }; 241 242 window.FuckAdBlock = FuckAdBlock; 243 244 if(window.fuckAdBlock === undefined) { 245 window.fuckAdBlock = new FuckAdBlock({ 246 checkOnLoad: true, 247 resetOnEnd: true 248 }); 249 } 250})(window);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.