HEX
Server: nginx
System: Linux pool195-106-36.bur.atomicsites.net 6.12.57+deb12-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.12.57-1~bpo12+1 (2025-11-17) x86_64
User: (0)
PHP: 8.3.32
Disabled: pcntl_fork
Upload Files
File: /wordpress/mu-plugins/wpcloud-bot-protection/assets/bootstrap.js
(function () {
	var cfg = window.__wpcloudBlackbox || {};
	if ( ! cfg.apiKey ) {
		return;
	}

	var isLog = cfg.mode === 'log';

	var form  = document.getElementById( 'loginform' ) || document.getElementById( 'lostpasswordform' );
	var field = document.getElementById( cfg.field );
	if ( ! form || ! field ) {
		return;
	}

	var challengeInProgress = false;

	var attempts = 0;
	( function whenReady() {
		if ( ! window.Blackbox || typeof window.Blackbox.configure !== 'function' ) {
			if ( attempts++ < 50 ) {
				window.setTimeout( whenReady, 100 );
			} else if ( window.console && window.console.warn ) {
				window.console.warn( '[wpcloud-blackbox] client did not load; gate inactive.' );
			}
			return;
		}

		try {
			window.Blackbox.configure( {
				apiKey: cfg.apiKey,
				challengeContainer: isLog ? null : document.getElementById( 'wpcloud-blackbox-challenge' ),
				onSuccess: function ( result ) {
					if ( result && result.sessionId ) {
						field.value = result.sessionId;
					}
				},
				onChallengeStart: function () {
					challengeInProgress = true;
				},
				onChallengeComplete: function () {
					challengeInProgress = false;
				},
				onChallengeFailure: function () {
					challengeInProgress = false;
				}
			} );
			window.Blackbox.init();
		} catch ( err ) {
		}
	} )();

	if ( ! isLog ) {
		var submitting = false;
		form.addEventListener( 'submit', function ( e ) {
			if ( submitting ) {
				return;
			}
			if ( ! window.Blackbox || typeof window.Blackbox.getSessionId !== 'function' ) {
				return;
			}
			if ( challengeInProgress ) {
				e.preventDefault();
				return;
			}
			if ( field.value ) {
				return;
			}

			e.preventDefault();
			submitting = true;

			var submitted = false;
			var submit = function () {
				if ( submitted ) { return; }
				submitted = true;
				if ( typeof form.requestSubmit === 'function' ) {
					form.requestSubmit();
				} else {
					form.submit();
				}
			};

			var safety = window.setTimeout( submit, 3000 );
			window.Blackbox.getSessionId()
				.then( function ( sid ) { if ( sid ) { field.value = sid; } } )
				.catch( function () {} )
				.then( function () { window.clearTimeout( safety ); submit(); } );
		} );
	}
})();