PageSourceSearch

https://www.taxi-money.net/media/account/auth-captcha.js?e4ac0c712b

js taxi-money.net collected 2026-09-30 10:58:48 UTC 8,851 bytes, 408 lines download raw bytes

1(function ($) {
2	'use strict';
3
4	var RECAPTCHA_URL = 'https://www.google.com/recaptcha/enterprise.js';
5	var loading = false;
6	var queue = [];
7	var loadedSiteKey = '';
8	var explicitLoaded = false;
9
10	function resolveCallback(callbackName) {
11		if (!callbackName || typeof window[callbackName] !== 'function') {
12			return undefined;
13		}
14
15		return window[callbackName];
16	}
17
18	function getEnterpriseApi() {
19		if (typeof window.grecaptcha === 'undefined' || !window.grecaptcha.enterprise) {
20			return null;
21		}
22
23		return window.grecaptcha.enterprise;
24	}
25
26	function whenRecaptchaReady(callback) {
27		var api = getEnterpriseApi();
28
29		if (!api) {
30			return;
31		}
32
33		if (typeof api.ready === 'function') {
34			api.ready(callback);
35			return;
36		}
37
38		callback();
39	}
40
41	function ensureTokenInput($form) {
42		var $input = $form.find('[name="g-recaptcha-response"]');
43
44		if (!$input.length) {
45			$input = $('<input type="hidden" name="g-recaptcha-response" value="" />');
46			$form.append($input);
47		}
48
49		return $input;
50	}
51
52	function ensureCaptchaModeInput($form) {
53		var $input = $form.find('[name="captcha_mode"]');
54
55		if (!$input.length) {
56			$input = $('<input type="hidden" name="captcha_mode" value="" />');
57			$form.append($input);
58		}
59
60		return $input;
61	}
62
63	function isCheckboxMode($form) {
64		return ensureCaptchaModeInput($form).val() === 'checkbox';
65	}
66
67	function getCheckboxSiteKey($form, checkboxKey) {
68		if (checkboxKey) {
69			return String(checkboxKey);
70		}
71
72		return String($form.attr('data-checkbox-sitekey') || '');
73	}
74
75	function runQueue() {
76		whenRecaptchaReady(function () {
77			var callbacks = queue.splice(0);
78			callbacks.forEach(function (callback) {
79				callback();
80			});
81		});
82	}
83
84	function loadRecaptchaScore(siteKey, callback) {
85		if (getEnterpriseApi() && loadedSiteKey === siteKey) {
86			whenRecaptchaReady(callback);
87			return;
88		}
89
90		queue.push(callback);
91
92		if (loading) {
93			return;
94		}
95
96		loading = true;
97		loadedSiteKey = siteKey;
98
99		window.txAuthRecaptchaOnLoad = function () {
100			loading = false;
101			runQueue();
102		};
103
104		var script = document.createElement('script');
105		script.src = RECAPTCHA_URL + '?render=' + encodeURIComponent(siteKey) + '&onload=txAuthRecaptchaOnLoad';
106		script.async = true;
107		script.onerror = function () {
108			loading = false;
109			loadedSiteKey = '';
110			queue = [];
111		};
112		document.head.appendChild(script);
113	}
114
115	function loadRecaptchaExplicit(callback) {
116		if (getEnterpriseApi()) {
117			explicitLoaded = true;
118			whenRecaptchaReady(callback);
119			return;
120		}
121
122		queue.push(callback);
123
124		if (loading) {
125			return;
126		}
127
128		loading = true;
129
130		window.txAuthRecaptchaOnLoad = function () {
131			loading = false;
132			explicitLoaded = true;
133			runQueue();
134		};
135
136		var script = document.createElement('script');
137		script.src = RECAPTCHA_URL + '?onload=txAuthRecaptchaOnLoad&render=explicit';
138		script.async = true;
139		script.onerror = function () {
140			loading = false;
141			queue = [];
142		};
143		document.head.appendChild(script);
144	}
145
146	function lockSubmitButton($button) {
147		if (typeof window.txLockAuthorizeSubmitBtn === 'function') {
148			return window.txLockAuthorizeSubmitBtn($button);
149		}
150
151		if (!$button || !$button.length || $button.prop('disabled')) {
152			return false;
153		}
154
155		$button.attr('disabled', 1);
156		return true;
157	}
158
159	function unlockSubmitButton($button) {
160		if (typeof window.txResetAuthorizeSubmitBtn === 'function') {
161			window.txResetAuthorizeSubmitBtn($button);
162			return;
163		}
164
165		if ($button && $button.length) {
166			$button.removeAttr('disabled');
167		}
168	}
169
170	function executeScoreRecaptcha($button) {
171		var siteKey = String($button.data('sitekey') || '');
172		var action = String($button.data('action') || 'SUBMIT');
173		var callback = resolveCallback($button.data('callback'));
174		var $form = $button.closest('form');
175
176		if (!siteKey) {
177			unlockSubmitButton($button);
178			return;
179		}
180
181		loadRecaptchaScore(siteKey, function () {
182			var api = getEnterpriseApi();
183
184			if (!api || typeof api.execute !== 'function') {
185				unlockSubmitButton($button);
186				return;
187			}
188
189			api.execute(siteKey, {action: action}).then(function (token) {
190				ensureTokenInput($form).val(token);
191
192				if (callback) {
193					callback(token);
194					return;
195				}
196
197				if (typeof window.txTriggerAuthorizeFormSubmit === 'function') {
198					window.txTriggerAuthorizeFormSubmit($form);
199				}
200			}).catch(function () {
201				unlockSubmitButton($button);
202			});
203		});
204	}
205
206	function renderCheckboxWidget($form, checkboxKey) {
207		var $container = $form.find('.authorize-captcha-fallback');
208
209		if (!$container.length) {
210			return;
211		}
212
213		loadRecaptchaExplicit(function () {
214			var api = getEnterpriseApi();
215
216			if (!api || typeof api.render !== 'function') {
217				return;
218			}
219
220			if ($form.data('tx-checkbox-widget-id') !== undefined) {
221				return;
222			}
223
224			var widgetId = api.render($container[0], {
225				sitekey: checkboxKey,
226				callback: function (token) {
227					ensureTokenInput($form).val(token);
228					$container.removeClass('has-error');
229				},
230				'expired-callback': function () {
231					ensureTokenInput($form).val('');
232				},
233			});
234
235			$form.data('tx-checkbox-widget-id', widgetId);
236		});
237	}
238
239	function syncCheckboxTokenField($form) {
240		ensureCaptchaModeInput($form).val('checkbox');
241
242		var api = getEnterpriseApi();
243		var widgetId = $form.data('tx-checkbox-widget-id');
244		var token = $form.find('input[type="hidden"][name="g-recaptcha-response"]').val() || '';
245
246		if (!token && api && widgetId !== undefined && typeof api.getResponse === 'function') {
247			token = api.getResponse(widgetId) || '';
248		}
249
250		if (!token) {
251			token = $form.find('textarea[name="g-recaptcha-response"]').val() || '';
252		}
253
254		if (!token) {
255			return '';
256		}
257
258		$form.find('input[type="hidden"][name="g-recaptcha-response"]').remove();
259		$form.append(
260			$('<input type="hidden" name="g-recaptcha-response" />').val(token)
261		);
262
263		return token;
264	}
265
266	window.txPrepareCaptchaForSubmit = function ($form) {
267		if (!$form || !$form.length || !isCheckboxMode($form)) {
268			return;
269		}
270
271		if ($form.find('input[type="hidden"][name="g-recaptcha-response"]').val()) {
272			ensureCaptchaModeInput($form).val('checkbox');
273			return;
274		}
275
276		syncCheckboxTokenField($form);
277	};
278
279	function executeCheckboxRecaptcha($button) {
280		var $form = $button.closest('form');
281		var $container = $form.find('.authorize-captcha-fallback');
282		var token = syncCheckboxTokenField($form);
283
284		if (!token) {
285			$container.addClass('has-error');
286			return;
287		}
288
289		if (!lockSubmitButton($button)) {
290			return;
291		}
292
293		$container.removeClass('has-error');
294
295		var $bot = $form.find('#bot');
296		if ($bot.length) {
297			$bot.val(1);
298		}
299
300		if (typeof window.txTriggerAuthorizeFormSubmit === 'function') {
301			window.txTriggerAuthorizeFormSubmit($form);
302		}
303	}
304
305	window.txEnterCaptchaFallback = function ($form, checkboxKey) {
306		if (!$form || !$form.length) {
307			return;
308		}
309
310		checkboxKey = getCheckboxSiteKey($form, checkboxKey);
311		if (!checkboxKey) {
312			return;
313		}
314
315		ensureCaptchaModeInput($form).val('checkbox');
316		$form.find('input[name="g-recaptcha-response"]').remove();
317		$form.find('.authorize-captcha-fallback').show();
318		renderCheckboxWidget($form, checkboxKey);
319	};
320
321	window.txResetEnterpriseCaptcha = function ($form) {
322		if (!$form || !$form.length) {
323			return;
324		}
325
326		$form.find('[name="g-recaptcha-response"]').val('');
327
328		if (!isCheckboxMode($form)) {
329			return;
330		}
331
332		var api = getEnterpriseApi();
333		var widgetId = $form.data('tx-checkbox-widget-id');
334
335		if (api && widgetId !== undefined && typeof api.reset === 'function') {
336			try {
337				api.reset(widgetId);
338			} catch (e) {
339			}
340		}
341
342		$form.find('[name="g-recaptcha-response"]').val('');
343	};
344
345	function primeRecaptcha($button) {
346		var $form = $button.closest('form');
347
348		if (isCheckboxMode($form)) {
349			renderCheckboxWidget($form, getCheckboxSiteKey($form));
350			return;
351		}
352
353		var siteKey = String($button.data('sitekey') || '');
354		if (!siteKey) {
355			return;
356		}
357
358		loadRecaptchaScore(siteKey, function () {});
359	}
360
361	function handleSubmitClick(event) {
362		var $button = $(event.currentTarget);
363
364		if (!$button.is('[data-recaptcha-lazy="true"]')) {
365			return;
366		}
367
368		event.preventDefault();
369		event.stopImmediatePropagation();
370
371		if ($button.prop('disabled')) {
372			return;
373		}
374
375		if (isCheckboxMode($button.closest('form'))) {
376			executeCheckboxRecaptcha($button);
377			return;
378		}
379
380		if (!lockSubmitButton($button)) {
381			return;
382		}
383
384		executeScoreRecaptcha($button);
385	}
386
387	$(function () {
388		var $buttons = $('.btn-submit[data-recaptcha-lazy="true"]');
389
390		if (!$buttons.length) {
391			return;
392		}
393
394		$buttons.each(function () {
395			var $button = $(this);
396			var $form = $button.closest('form');
397
398			$form.one('focusin', function () {
399				primeRecaptcha($button);
400			});
401			$button.one('mouseenter', function () {
402				primeRecaptcha($button);
403			});
404		});
405
406		$(document).on('click', '.btn-submit[data-recaptcha-lazy="true"]', handleSubmitClick);
407	});
408})(jQuery);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.