sweetbean.protection.bot_detection
Bot/agent detection protection.
Wraps assets/bot-detection.js (a self-contained IIFE that exposes a
BotDetection global) and wires it into the SweetBean compile flow:
- :meth:
runtime_js— inlines the IIFE sowindow.BotDetectionexists beforeinitJsPsychruns. - :meth:
init_js— callsBotDetection.initializeand (optionally) installs a single document-levelinputlistener that records every range-slider move. This removes the need for a per-stimulus mixin: any<input type="range">(jsPsych's slider plugin or any custom slider) is automatically tracked. - :meth:
on_load_for_stimulus— resets per-trial slider tracking. - :meth:
on_finish_for_stimulus— feeds the trial RT into the cumulative buffer and merges per-trial slider stats + the running bot-detection summary into the data row. - :meth:
summary_js— emitsBotDetection.getSummary()so the experiment'son_finishadds the full summary to every saved row viajsPsych.data.addProperties.
BotDetection
Bases: Protection
Bot/agent detection layer.
Source code in sweetbean/protection/bot_detection.py
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | |
__init__(enable_countermeasures=True, track_sliders=True)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
enable_countermeasures
|
bool
|
when False, only passive logging runs — no honeypot DOM, no clipboard/devtools blocking, no inline traps. Useful for pilots / debugging. |
True
|
track_sliders
|
bool
|
when True, install a document-level |
True
|
Source code in sweetbean/protection/bot_detection.py
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | |