captsa add alert
This commit is contained in:
@@ -122,3 +122,25 @@ def command_result(cmd_id):
|
||||
conn.commit()
|
||||
conn.close()
|
||||
return jsonify({'ok': True})
|
||||
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
# POST /api/captcha/alert
|
||||
# Tampermonkey reports when #hcaptcha_window appears/disappears.
|
||||
# Body: { detected: true | false }
|
||||
# ------------------------------------------------------------------
|
||||
@api.route('/api/captcha/alert', methods=['POST'])
|
||||
def captcha_alert():
|
||||
data = request.get_json(silent=True) or {}
|
||||
detected = bool(data.get('detected', False))
|
||||
conn = get_db()
|
||||
conn.execute('''
|
||||
INSERT INTO kv_store (key, value, updated_at)
|
||||
VALUES ('captcha_active', ?, ?)
|
||||
ON CONFLICT(key) DO UPDATE SET
|
||||
value = excluded.value,
|
||||
updated_at = excluded.updated_at
|
||||
''', ('1' if detected else '0', datetime.utcnow().isoformat()))
|
||||
conn.commit()
|
||||
conn.close()
|
||||
return jsonify({'ok': True})
|
||||
|
||||
Reference in New Issue
Block a user