1var d = new Date(), 2 ctTimeMs = new Date().getTime(), 3 ctMouseEventTimerFlag = true, //Reading interval flag 4 ctMouseData = "[", 5 ctMouseDataCounter = 0, 6 ctScrollCollected = false; 7 8function ctSetCookie(cookies) { 9 let useAltCookies = ct_use_alt_cookies; 10 11 if(useAltCookies === 1) { 12 let xhr = new XMLHttpRequest(); 13 14 let json = JSON.stringify(cookies); 15 16 xhr.open("POST", '/admin/config/cleantalk/set_alt_cookies') 17 xhr.setRequestHeader('Content-type', 'application/json; charset=utf-8'); 18 19 xhr.send(json); 20 } else { 21 cookies.forEach(function (e) { 22 document.cookie = e.name + "=" + encodeURIComponent(e.value) + "; path=/"; 23 }) 24 } 25} 26 27ctSetCookie( 28 [ 29 { 30 'name' : 'ct_check_js', 31 'value' : ct_check_js_val 32 }, 33 { 34 'name' : 'ct_ps_timestamp', 35 'value' : Math.floor(new Date().getTime()/1000) 36 }, 37 { 38 'name' : 'ct_fkp_timestamp', 39 'value' : '0' 40 }, 41 { 42 'name' : 'ct_pointer_data', 43 'value' : '0' 44 }, 45 { 46 'name' : 'ct_timezone', 47 'value' : d.getTimezoneOffset()/60*(-1) 48 }, 49 { 50 'name' : 'apbct_antibot', 51 'value' : drupal_ac_antibot_cookie_value 52 }, 53 { 54 'name' : 'ct_has_scrolled', 55 'value' : false 56 } 57 ] 58); 59 60//Reading interval 61 62var ctMouseReadInterval = setInterval(function() { 63 ctMouseEventTimerFlag = true; 64 }, 150); 65 66//Writting interval 67 68var ctMouseWriteDataInterval = setInterval(function() { 69 if(typeof ct_use_alt_cookies !== "undefined" && ct_use_alt_cookies === 1) { 70 return; 71 } 72 var ctMouseDataToSend = ctMouseData.slice(0,-1).concat("]"); 73 ctSetCookie([ 74 { 75 'name' : 'ct_pointer_data', 76 'value' : ctMouseDataToSend 77 } 78 ]); 79 }, 1200); 80 81//Stop observing function 82 83function ctMouseStopData() { 84 if(typeof window.addEventListener == "function") 85 window.removeEventListener("mousemove", ctFunctionMouseMove); 86 else 87 window.detachEvent("onmousemove", ctFunctionMouseMove); 88 clearInterval(ctMouseReadInterval); 89 clearInterval(ctMouseWriteDataInterval); 90} 91 92//Logging mouse position each 300 ms 93 94var ctFunctionMouseMove = function output(event) { 95 if (ctMouseEventTimerFlag == true) { 96 var mouseDate = new Date(); 97 ctMouseData += "[" + Math.round(event.pageY) + "," + Math.round(event.pageX) + "," + Math.round(mouseDate.getTime() - ctTimeMs) + "],"; 98 ctMouseDataCounter++; 99 ctMouseEventTimerFlag = false; 100 if(ctMouseDataCounter >= 100) 101 ctMouseStopData(); 102 } 103}; 104 105/** 106 * Set scrolling cookie 107 */ 108function ctSetHasScrolled() { 109 if( ! ctScrollCollected ) { 110 ctSetCookie([ 111 { 112 'name' : 'ct_has_scrolled', 113 'value' : true 114 } 115 ]); 116 ctScrollCollected = true; 117 } 118} 119 120//Stop key listening function 121 122function ctKeyStopStopListening() { 123 if (typeof window.addEventListener == "function") { 124 window.removeEventListener("mousedown", ctFunctionFirstKey); 125 window.removeEventListener("keydown", ctFunctionFirstKey); 126 } 127 else { 128 window.detachEvent("mousedown", ctFunctionFirstKey); 129 window.detachEvent("keydown", ctFunctionFirstKey); 130 } 131} 132 133//Writing first key press timestamp 134 135var ctFunctionFirstKey = function output(event) { 136 var KeyTimestamp = Math.floor(new Date().getTime()/1000); 137 ctSetCookie([ 138 { 139 'name' : 'ct_fkp_timestamp', 140 'value' : KeyTimestamp 141 } 142 ]); 143 ctKeyStopStopListening(); 144}; 145 146if (typeof window.addEventListener == "function") { 147 window.addEventListener("mousemove", ctFunctionMouseMove); 148 window.addEventListener("mousedown", ctFunctionFirstKey); 149 window.addEventListener("keydown", ctFunctionFirstKey); 150 window.addEventListener("scroll", ctSetHasScrolled); 151} 152else { 153 window.attachEvent("onmousemove", ctFunctionMouseMove); 154 window.attachEvent("mousedown", ctFunctionFirstKey); 155 window.attachEvent("keydown", ctFunctionFirstKey); 156 window.attachEvent("scroll", ctSetHasScrolled); 157} 158 159function apbct_collect_visible_fields( form ) { 160 161 // Get only fields 162 var inputs = [], 163 inputs_visible = '', 164 inputs_visible_count = 0, 165 inputs_invisible = '', 166 inputs_invisible_count = 0, 167 inputs_with_duplicate_names = []; 168 169 for(var key in form.elements){ 170 if(!isNaN(+key)) 171 inputs[key] = form.elements[key]; 172 } 173 174 // Filter fields
175 inputs = inputs.filter(function(elem){ 176 177 // Filter already added fields 178 if( inputs_with_duplicate_names.indexOf( elem.getAttribute('name') ) !== -1 ){ 179 return false; 180 } 181 // Filter inputs with same names for type == radio 182 if( -1 !== ['radio', 'checkbox'].indexOf( elem.getAttribute("type") )){ 183 inputs_with_duplicate_names.push( elem.getAttribute('name') ); 184 return false; 185 } 186 return true; 187 }); 188 189 // Visible fields 190 inputs.forEach(function(elem, i, elements){ 191 // Unnecessary fields 192 if( 193 elem.getAttribute("type") === "submit" || // type == submit 194 elem.getAttribute('name') === null || 195 elem.getAttribute('name') === 'ct_checkjs' 196 ) { 197 return; 198 } 199 // Invisible fields 200 if( 201 getComputedStyle(elem).display === "none" || // hidden 202 getComputedStyle(elem).visibility === "hidden" || // hidden 203 getComputedStyle(elem).opacity === "0" || // hidden 204 elem.getAttribute("type") === "hidden" // type == hidden 205 ) { 206 if( elem.classList.contains("wp-editor-area") ) { 207 inputs_visible += " " + elem.getAttribute("name"); 208 inputs_visible_count++; 209 } else { 210 inputs_invisible += " " + elem.getAttribute("name"); 211 inputs_invisible_count++; 212 } 213 } 214 // Visible fields 215 else { 216 inputs_visible += " " + elem.getAttribute("name"); 217 inputs_visible_count++; 218 } 219 220 }); 221 222 inputs_invisible = inputs_invisible.trim(); 223 inputs_visible = inputs_visible.trim(); 224 225 return { 226 visible_fields : inputs_visible, 227 visible_fields_count : inputs_visible_count, 228 invisible_fields : inputs_invisible, 229 invisible_fields_count : inputs_invisible_count, 230 } 231 232} 233 234function apbct_visible_fields_set_cookie( visible_fields_collection ) { 235 236 var collection = typeof visible_fields_collection === 'object' && visible_fields_collection !== null ? visible_fields_collection : {}; 237 238 ctSetCookie([ 239 { 240 'name' : 'apbct_visible_fields', 241 'value' : JSON.stringify( collection ) 242 } 243 ]) 244}
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.