1/** 2 * Shared reCAPTCHA v2 token store + POST to TrueCaptcha /recaptcha API. 3 * Load after js/utils/async.js, before demo.js / login.js / upload.js. 4 */ 5(function () { 6 var token = null; 7 8 window.tcRecaptcha = { 9 getToken: function () { 10 return token; 11 }, 12 setToken: function (t) { 13 token = t; 14 }, 15 clearToken: function () { 16 token = null; 17 }, 18 reload: function () { 19 token = null; 20 if (typeof grecaptcha !== 'undefined' && grecaptcha && typeof grecaptcha.reset === 'function') { 21 try { 22 grecaptcha.reset(); 23 } catch (e) {} 24 } 25 } 26 }; 27 28 /** HTML data-callback (signup, components/demo.html, upload-only pages). */ 29 window.recaptcha_callback = function (t) { 30 tcRecaptcha.setToken(t); 31 }; 32})(); 33 34/** Legacy name â same as tcRecaptcha.reload(). */ 35function recaptcha_reload() { 36 tcRecaptcha.reload(); 37} 38 39function get_recaptcha_api_url() { 40 if (typeof window.SITE_CONFIG !== 'undefined' && window.SITE_CONFIG.getRecaptchaUrl) { 41 return window.SITE_CONFIG.getRecaptchaUrl(); 42 } 43 return 'https://api.apitruecaptcha.org/one/recaptcha'; 44} 45 46/** 47 * POST JSON to recaptcha solve endpoint (same contract as legacy demo.js / upload.js fetch_text). 48 * @returns {Promise<[*, string|null]>} [result, errorString] â error null on success 49 */ 50async function post_recaptcha_api(params) { 51 var url = get_recaptcha_api_url(); 52 try { 53 var response = await fetch(url, { 54 method: 'post', 55 body: JSON.stringify(params) 56 }); 57 if (!response.ok) return [null, 'HTTP ' + response.status]; 58 var data = await response.json(); 59 console.log('post_recaptcha_api', data); 60 if (data.error) return [null, data.error]; 61 return [data.result, null]; 62 } catch (err) { 63 return [null, 'SERVER ERROR TIMEOUT:' + (err && err.message ? err.message : '')]; 64 } 65}
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.