first commit

This commit is contained in:
phil 2023-09-30 09:40:37 +02:00
commit 346d1cb29d
287 changed files with 43533 additions and 0 deletions

View file

@ -0,0 +1,23 @@
.antibot-message {
border: 1px solid;
border-width: 1px 1px 1px 0;
border-radius: 2px;
padding: 15px;
word-wrap: break-word;
overflow-wrap: break-word;
margin: 9px 0 10px 8px;
}
.antibot-message-warning {
background-color: #fdf8ed;
border-color: #f4daa6 #f4daa6 #f4daa6 transparent;
color: #734c00;
box-shadow: -8px 0 0 #e09600;
}
.antibot-message-error {
background-color: #fcf4f2;
color: #a51b00;
border-color: #f9c9bf #f9c9bf #f9c9bf transparent;
box-shadow: -8px 0 0 #e62600;
}

View file

@ -0,0 +1,70 @@
/**
* @file
* Unlock protected forms.
*
* This works by resetting the form action to the path that It should be as well
* as injecting the secret form key, only if the current user is verified to be
* human which is done by waiting for a mousemove, swipe, or tab/enter key to be
* pressed.
*/
(function (Drupal, drupalSettings) {
"use strict";
Drupal.antibot = {};
Drupal.behaviors.antibot = {
attach: function (context) {
// Assume the user is not human, despite JS being enabled.
drupalSettings.antibot.human = false;
// Wait for a mouse to move, indicating they are human.
document.body.addEventListener('mousemove', function () {
// Unlock the forms.
Drupal.antibot.unlockForms();
});
// Wait for a touch move event, indicating that they are human.
document.body.addEventListener('touchmove', function () {
// Unlock the forms.
Drupal.antibot.unlockForms();
});
// A tab or enter key pressed can also indicate they are human.
document.body.addEventListener('keydown', function (e) {
if ((e.code == 'Tab') || (e.code == 'Enter')) {
// Unlock the forms.
Drupal.antibot.unlockForms();
}
});
}
};
/**
* Unlock all locked forms.
*/
Drupal.antibot.unlockForms = function () {
// Act only if we haven't yet verified this user as being human.
if (!drupalSettings.antibot.human) {
// Check if there are forms to unlock.
if (drupalSettings.antibot.forms != undefined) {
// Iterate all antibot forms that we need to unlock.
Object.values(drupalSettings.antibot.forms).forEach(function (config) {
// Switch the action.
const form = document.getElementById(config.id);
if (form) {
form.setAttribute('action', form.getAttribute('data-action'));
// Set the key.
const input = form.querySelector('input[name="antibot_key"]');
if (input) {
input.value = config.key;
}
}
});
}
// Mark this user as being human.
drupalSettings.antibot.human = true;
}
};
})(Drupal, drupalSettings);