-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
increace js protection exclude js code to external js file
- Loading branch information
davydovct
committed
Jul 9, 2018
1 parent
5de2766
commit 0609d7e
Showing
10 changed files
with
414 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
119 changes: 119 additions & 0 deletions
119
2.3.x/upload/catalog/view/javascript/antispambycleantalk.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
var ct_date = new Date(), | ||
ctTimeMs = new Date().getTime(), | ||
ctMouseEventTimerFlag = true, //Reading interval flag | ||
ctMouseData = [], | ||
ctMouseDataCounter = 0; | ||
|
||
function ctSetCookieSec(c_name, value) { | ||
document.cookie = c_name + "=" + encodeURIComponent(value) + "; path=/"; | ||
} | ||
|
||
function apbct_attach_event_handler(elem, event, callback){ | ||
if(typeof window.addEventListener == "function") elem.addEventListener(event, callback); | ||
else elem.attachEvent(event, callback); | ||
} | ||
|
||
function apbct_remove_event_handler(elem, event, callback){ | ||
if(typeof window.removeEventListener == "function") elem.removeEventListener(event, callback); | ||
else elem.detachEvent(event, callback); | ||
} | ||
|
||
ctSetCookieSec("apbct_ps_timestamp", Math.floor(new Date().getTime()/1000)); | ||
ctSetCookieSec("apbct_fkp_timestamp", "0"); | ||
ctSetCookieSec("apbct_pointer_data", "0"); | ||
ctSetCookieSec("apbct_timezone", "0"); | ||
|
||
setTimeout(function(){ | ||
ctSetCookieSec("apbct_timezone", ct_date.getTimezoneOffset()/60*(-1)); | ||
},1000); | ||
|
||
//Writing first key press timestamp | ||
var ctFunctionFirstKey = function output(event){ | ||
var KeyTimestamp = Math.floor(new Date().getTime()/1000); | ||
ctSetCookieSec("ct_fkp_timestamp", KeyTimestamp); | ||
ctKeyStopStopListening(); | ||
} | ||
|
||
//Reading interval | ||
var ctMouseReadInterval = setInterval(function(){ | ||
ctMouseEventTimerFlag = true; | ||
}, 150); | ||
|
||
//Writting interval | ||
var ctMouseWriteDataInterval = setInterval(function(){ | ||
ctSetCookieSec("apbct_pointer_data", JSON.stringify(ctMouseData)); | ||
}, 1200); | ||
|
||
//Logging mouse position each 150 ms | ||
var ctFunctionMouseMove = function output(event){ | ||
if(ctMouseEventTimerFlag == true){ | ||
|
||
ctMouseData.push([ | ||
Math.round(event.pageY), | ||
Math.round(event.pageX), | ||
Math.round(new Date().getTime() - ctTimeMs) | ||
]); | ||
|
||
ctMouseDataCounter++; | ||
ctMouseEventTimerFlag = false; | ||
if(ctMouseDataCounter >= 50){ | ||
ctMouseStopData(); | ||
} | ||
} | ||
} | ||
|
||
//Stop mouse observing function | ||
function ctMouseStopData(){ | ||
apbct_remove_event_handler(window, "mousemove", ctFunctionMouseMove); | ||
clearInterval(ctMouseReadInterval); | ||
clearInterval(ctMouseWriteDataInterval); | ||
} | ||
|
||
//Stop key listening function | ||
function ctKeyStopStopListening(){ | ||
apbct_remove_event_handler(window, "mousedown", ctFunctionFirstKey); | ||
apbct_remove_event_handler(window, "keydown", ctFunctionFirstKey); | ||
} | ||
|
||
apbct_attach_event_handler(window, "mousemove", ctFunctionMouseMove); | ||
apbct_attach_event_handler(window, "mousedown", ctFunctionFirstKey); | ||
apbct_attach_event_handler(window, "keydown", ctFunctionFirstKey); | ||
|
||
// Ready function | ||
function apbct_ready(){ | ||
ctSetCookieSec("apbct_visible_fields", 0); | ||
ctSetCookieSec("apbct_visible_fields_count", 0); | ||
if (document.getElementById("ct_checkjs")) | ||
document.getElementById("ct_checkjs").value = ct_date.getFullYear(); | ||
setTimeout(function(){ | ||
for(var i = 0; i < document.forms.length; i++){ | ||
var form = document.forms[i]; | ||
form.onsubmit_prev = form.onsubmit; | ||
form.onsubmit = function(event){ | ||
this.visible_fields = ''; | ||
this.visible_fields_count = this.elements.length; | ||
for(var j = 0; j < this.elements.length; j++){ | ||
var elem = this.elements[j]; | ||
if( getComputedStyle(elem).display == "none" || | ||
getComputedStyle(elem).visibility == "hidden" || | ||
getComputedStyle(elem).width == "0" || | ||
getComputedStyle(elem).heigth == "0" || | ||
getComputedStyle(elem).opacity == "0" || | ||
elem.getAttribute("type") == "hidden" || | ||
elem.getAttribute("type") == "submit" | ||
){ | ||
this.visible_fields_count--; | ||
}else{ | ||
this.visible_fields += (this.visible_fields == "" ? "" : " ") + elem.getAttribute("name"); | ||
} | ||
} | ||
ctSetCookieSec("apbct_visible_fields", this.visible_fields); | ||
ctSetCookieSec("apbct_visible_fields_count", this.visible_fields_count); | ||
if(this.onsubmit_prev instanceof Function){ | ||
this.onsubmit_prev.call(this, event); | ||
} | ||
} | ||
} | ||
}, 1000); | ||
} | ||
apbct_attach_event_handler(window, "DOMContentLoaded", apbct_ready); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.