我使用了以下技术:检测复制/粘贴并计算击键之间的间隔。这是我的代码。
HTML
JS
var x = -1;
var delta = 0;
var count = 0;
function detectHumans() {
count += 1;
if ($("#card_number").val().length != count) {
alert('human detected');
$("body").html('');
}
console.log($("#card_number").val());
y = Date.now();
if (x == -1) {
x = y;
}
else if (delta == 0) {
delta = y - x;
x = y;
}
else{
var new_delta = y - x;
console.log(delta);
console.log(new_delta);
if (Math.abs(new_delta - delta) > 10) {
alert('human detected');
$("body").html('');
}
delta = new_delta;
x = y;
}
}