1apbctLocalStorage = { 2 get : function(key, property) { 3 if ( typeof property === 'undefined' ) { 4 property = 'value'; 5 } 6 const storageValue = localStorage.getItem(key); 7 if ( storageValue !== null ) { 8 try { 9 const json = JSON.parse(storageValue); 10 return json.hasOwnProperty(property) ? JSON.parse(json[property]) : json; 11 } catch (e) { 12 return storageValue; 13 } 14 } 15 return false; 16 }, 17 set : function(key, value, is_json = true) { 18 if (is_json){ 19 let objToSave = {'value': JSON.stringify(value), 'timestamp': Math.floor(new Date().getTime() / 1000)}; 20 localStorage.setItem(key, JSON.stringify(objToSave)); 21 } else { 22 localStorage.setItem(key, value); 23 } 24 }, 25 isAlive : function(key, maxLifetime) { 26 if ( typeof maxLifetime === 'undefined' ) { 27 maxLifetime = 86400; 28 } 29 const keyTimestamp = this.get(key, 'timestamp'); 30 return keyTimestamp + maxLifetime > Math.floor(new Date().getTime() / 1000); 31 }, 32 isSet : function(key) { 33 return localStorage.getItem(key) !== null; 34 }, 35 delete : function (key) { 36 localStorage.removeItem(key); 37 }, 38 getCleanTalkData : function () { 39 let data = {} 40 for(let i=0; i<localStorage.length; i++) { 41 let key = localStorage.key(i); 42 if (key.indexOf('ct_') !==-1 || key.indexOf('apbct_') !==-1){ 43 data[key.toString()] = apbctLocalStorage.get(key) 44 } 45 } 46 return data 47 }, 48 49} 50 51function ctSetCookie(c_name, value) { 52 if (typeof ct_setcookie !== "undefined" && ct_setcookie) { 53 document.cookie = c_name + "=" + encodeURIComponent(value) + "; path=/"; 54 } 55} 56 57/** 58 * Set some cookies from object 59 * @param cookies 60 */ 61function ctSetCookies(cookies) 62{ 63 if (typeof ctPublicData !== 'undefined' && ctPublicData.typeOfCookie && ctPublicData.typeOfCookie === 'alt_cookies') { 64 ctSetAltCookies(cookies); 65 } else { 66 for (const [cookie, value] of Object.entries(cookies)) { 67 ctSetCookie(cookie, value); 68 } 69 } 70} 71 72ct_attach_event_handler(window, "DOMContentLoaded", ct_ready); 73 74//Stop observing function 75function ctMouseStopData(){ 76 if(typeof window.addEventListener == "function") 77 window.removeEventListener("mousemove", ctFunctionMouseMove); 78 else 79 window.detachEvent("onmousemove", ctFunctionMouseMove); 80 clearInterval(ctMouseReadInterval); 81 clearInterval(ctMouseWriteDataInterval); 82} 83 84//Stop key listening function 85function ctKeyStopStopListening(){ 86 if(typeof window.addEventListener == "function"){ 87 window.removeEventListener("mousedown", ctFunctionFirstKey); 88 window.removeEventListener("keydown", ctFunctionFirstKey); 89 }else{ 90 window.detachEvent("mousedown", ctFunctionFirstKey); 91 window.detachEvent("keydown", ctFunctionFirstKey); 92 } 93} 94 95var d = new Date(), 96 ctTimeMs = new Date().getTime(), 97 ctMouseEventTimerFlag = true, //Reading interval flag 98 ctMouseData = "[", 99 ctMouseDataCounter = 0; 100 101//Reading interval 102var ctMouseReadInterval = setInterval(function(){ 103 ctMouseEventTimerFlag = true; 104}, 150); 105 106//Writting interval 107var ctMouseWriteDataInterval = setInterval(function(){ 108 var ctMouseDataToSend = ctMouseData.slice(0,-1).concat("]"); 109 if (typeof ctPublicData !== 'undefined' && ctPublicData.typeOfCookie && ctPublicData.typeOfCookie === 'alt_cookies') { 110 apbctLocalStorage.set('ct_pointer_data', ctMouseDataToSend); 111 } else { 112 ctSetCookie('ct_pointer_data', ctMouseDataToSend); 113 } 114}, 1200); 115 116//Logging mouse position each 300 ms 117var ctFunctionMouseMove = function output(event){ 118 if(ctMouseEventTimerFlag == true){ 119 var mouseDate = new Date(); 120 ctMouseData += "[" + event.pageY + "," + event.pageX + "," + (mouseDate.getTime() - ctTimeMs) + "],"; 121 ctMouseDataCounter++; 122 ctMouseEventTimerFlag = false; 123 if(ctMouseDataCounter >= 100) 124 ctMouseStopData(); 125 } 126} 127//Writing first key press timestamp 128var ctFunctionFirstKey = function output(event){ 129 var KeyTimestamp = Math.floor(new Date().getTime()/1000); 130 if (typeof ctPublicData !== 'undefined' && ctPublicData.typeOfCookie && ctPublicData.typeOfCookie === 'alt_cookies') { 131 ctSetAltCookies({'ct_fkp_timestamp': KeyTimestamp}); 132 } else {
133 ctSetCookie('ct_fkp_timestamp', KeyTimestamp); 134 } 135 ctKeyStopStopListening(); 136} 137 138if(typeof window.addEventListener == "function"){ 139 window.addEventListener("mousemove", ctFunctionMouseMove); 140 window.addEventListener("mousedown", ctFunctionFirstKey); 141 window.addEventListener("keydown", ctFunctionFirstKey); 142}else{ 143 window.attachEvent("onmousemove", ctFunctionMouseMove); 144 window.attachEvent("mousedown", ctFunctionFirstKey); 145 window.attachEvent("keydown", ctFunctionFirstKey); 146} 147// Ready function 148function ct_ready(){ 149 const cookies = { 150 ct_ps_timestamp: Math.floor(new Date().getTime()/1000), 151 ct_fkp_timestamp: 0, 152 ct_pointer_data: 0, 153 ct_timezone: new Date().getTimezoneOffset()/60*(-1), 154 ct_visible_fields: 0, 155 ct_visible_fields_count: 0 156 } 157 158 ctSetCookies(cookies); 159 160 setTimeout(function(){ 161 for(var i = 0; i < document.forms.length; i++){ 162 var form = document.forms[i]; 163 164 checkEasySocial(form); 165 166 if (!form.name && !form.id) { 167 continue; 168 } 169 170 // Exclude `cbactivity` plugin: has conflicted. 171 if ( form.classList.contains('streamItemForm') ) { 172 continue; 173 } 174 175 // Exclude hikashop updatecart form 176 if ( form.action.indexOf('updatecart') !== -1 ) { 177 continue; 178 } 179 180 // Get only fields 181 var elements = []; 182 for(var key in this.elements){ 183 if(!isNaN(+key)) 184 elements[key] = this.elements[key]; 185 } 186 187 // Filter fields 188 elements = elements.filter(function(elem){ 189 190 var pass = true; 191 192 // Filter fields 193 if( getComputedStyle(elem).display === "none" || // hidden 194 getComputedStyle(elem).visibility === "hidden" || // hidden 195 getComputedStyle(elem).opacity === "0" || // hidden 196 elem.getAttribute("type") === "hidden" || // type == hidden 197 elem.getAttribute("type") === "submit" || // type == submit 198 elem.value === "" || // empty value 199 elem.getAttribute('name') === null 200 ){ 201 return false; 202 } 203 204 // Filter elements with same names for type == radio 205 if(elem.getAttribute("type") === "radio"){ 206 elements.forEach(function(el, j, els){ 207 if(elem.getAttribute('name') === el.getAttribute('name')){ 208 pass = false; 209 return; 210 } 211 }); 212 } 213 214 return true; 215 }); 216 217 // Visible fields count 218 var visible_fields_count = elements.length; 219 220 // Visible fields 221 var visible_fields = ''; 222 elements.forEach(function(elem, i, elements){ 223 visible_fields += " " + elem.getAttribute("name"); 224 }); 225 visible_fields = visible_fields.trim(); 226 227 form.onsubmit_prev = form.onsubmit; 228 229 form.onsubmit = function(event, visible_fields, visible_fields_count) { 230 if (event === undefined) { 231 return; 232 } 233 if (typeof ctPublicData !== 'undefined' && ctPublicData.typeOfCookie && ctPublicData.typeOfCookie === 'alt_cookies') { 234 const cookies = { 235 ct_pointer_data: apbctLocalStorage.get('ct_pointer_data'), 236 ct_visible_fields: visible_fields, 237 ct_visible_fields_count: visible_fields_count 238 } 239 ctSetAltCookies(cookies); 240 } else { 241 ctSetCookie("ct_visible_fields", visible_fields); 242 ctSetCookie("ct_visible_fields_count", visible_fields_count); 243 } 244 245 // Call previous submit action 246 if (event.target.onsubmit_prev instanceof Function && !ct_is_excluded_forms(event.target)) { 247 setTimeout(function() { 248 event.target.onsubmit_prev.call(event.target, event); 249 }, 500); 250 } 251 } 252 } 253 }, 1000); 254} 255 256function checkEasySocial(form) { 257 if (form.classList.contains('es-form-login')) { 258 form.querySelectorAll('a.btn').forEach(function (el) { 259 if (el.hasAttribute('data-oauth-login-button')) { 260 el.removeAttribute('data-oauth-login-button'); 261 el.setAttribute('data-oauth-login-button-blocked', ''); 262 } 263 el.onclick = function(e) { 264 e.preventDefault(); 265 let allow = function(target) { 266 if (target.hasAttribute('data-oauth-login-button-blocked')) { 267 target.removeAttribute('data-oauth-login-button-blocked'); 268 target.setAttribute('data-oauth-login-button', ''); 269 } 270 target.onclick = null; 271 target.click(); 272 }; 273 let forbidden = function(target, msg) { 274 let el = document.createElement('div'); 275 el.style.background = 'red'; 276 el.style.color = 'white'; 277 el.style.padding = '1em'; 278 el.style.margin = '1em'; 279 el.innerHTML = msg; 280 target.insertAdjacentElement('afterend', el); 281 }; 282 283 ctCheckAjax(e.target, allow, forbidden); 284 285 return false;
286 } 287 }) 288 } 289} 290 291function ct_is_excluded_forms(form) { 292 if (form.onsubmit_prev && form.onsubmit_prev.toString().includes('validateRegistrationForm')) { 293 return true; 294 } 295 296 let value; 297 for (let key in form.elements){ 298 if (isNaN(+key)) { 299 continue; 300 } 301 302 value = form.elements[key]; 303 if (value.classList.contains('cf-input')) { 304 return true; 305 } 306 if (value.classList.contains('ff_elem bfCalendarInput')) { 307 return true; 308 } 309 } 310 311 return false; 312} 313 314function ct_attach_event_handler(elem, event, callback){ 315 if(typeof window.addEventListener === "function") elem.addEventListener(event, callback); 316 else elem.attachEvent(event, callback); 317} 318 319function ct_remove_event_handler(elem, event, callback){ 320 if(typeof window.removeEventListener === "function") elem.removeEventListener(event, callback); 321 else elem.detachEvent(event, callback); 322} 323 324function ct_attach_event_token(){ 325 if (typeof apbctLocalStorage !== "undefined"){ 326 const ct_event_token_string = apbctLocalStorage.get('bot_detector_event_token') 327 const ct_event_token_obj = JSON.parse(ct_event_token_string.toString()) 328 if (typeof ctSetCookie == "function" && typeof ct_event_token_obj.value != "undefined"){ 329 const value = ct_event_token_obj.value; 330 if (typeof value === "string" && value.length === 64){ 331 if (typeof ctPublicData !== 'undefined' && ctPublicData.typeOfCookie && ctPublicData.typeOfCookie === 'alt_cookies') { 332 ctSetAltCookies({'ct_event_token': ct_event_token_obj.value}); 333 } else { 334 ctSetCookie("ct_event_token", ct_event_token_obj.value); 335 } 336 337 return true; 338 } 339 } 340 } 341 return false; 342} 343 344// Setting alt-cookies from array 345function ctSetAltCookies(altCookies) 346{ 347 altCookies.action = 'set_alt_cookies'; 348 349 Joomla.request({ 350 url: 'index.php?option=com_ajax&plugin=cleantalkantispam&format=raw', 351 method: 'POST', 352 data: JSON.stringify(altCookies), 353 headers: { 354 'Cache-Control' : 'no-cache', 355 'Content-Type': 'application/json' 356 }, 357 onSuccess: function (response){ 358 console.log(response); 359 }, 360 onError: function (error){ 361 console.log(error); 362 } 363 }); 364} 365 366function ctCheckAjax(target, allow, forbidden) 367{ 368 let data = apbctLocalStorage.getCleanTalkData(); 369 data.action = 'check_ajax'; 370 371 Joomla.request({ 372 url: 'index.php?option=com_ajax&plugin=cleantalkantispam&format=raw', 373 method: 'POST', 374 data: JSON.stringify(data), 375 headers: { 376 'Cache-Control' : 'no-cache', 377 'Content-Type': 'application/json' 378 }, 379 onSuccess: function (response){ 380 let result = JSON.parse(response); 381 382 if (result && result.allow == 1) { 383 allow(target); 384 } 385 386 if (result && result.allow == 0) { 387 forbidden(target, result.msg); 388 } 389 }, 390 onError: function (error){ 391 console.log('error', error); 392 } 393 }); 394}
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.