| 1 |
"use strict"; |
| 2 |
|
| 3 |
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } |
| 4 |
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); } |
| 5 |
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } } |
| 6 |
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; } |
| 7 |
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; } |
| 8 |
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } |
| 9 |
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); } |
| 10 |
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } |
| 11 |
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } } |
| 12 |
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; } |
| 13 |
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } } |
| 14 |
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; } |
| 15 |
(function () { |
| 16 |
'use strict'; |
| 17 |
|
| 18 |
var css = '.frc-captcha *{margin:0;padding:0;border:0;text-align:initial;border-radius:0;filter:none!important;transition:none!important;font-weight:400;font-size:14px;line-height:1.2;text-decoration:none;background-color:initial;color:#222}.frc-captcha{position:relative;min-width:250px;max-width:312px;border:1px solid #f4f4f4;padding-bottom:12px;background-color:#fff}.frc-captcha b{font-weight:700}.frc-container{display:flex;align-items:center;min-height:52px}.frc-icon{fill:#222;stroke:#222;flex-shrink:0;margin:8px 8px 0}.frc-icon.frc-warning{fill:#c00}.frc-success .frc-icon{animation:1s ease-in both frc-fade-in}.frc-content{white-space:nowrap;display:flex;flex-direction:column;margin:4px 6px 0 0;overflow-x:auto;flex-grow:1}.frc-banner{position:absolute;bottom:0;right:6px;line-height:1}.frc-banner *{font-size:10px;opacity:.8;text-decoration:none}.frc-progress{-webkit-appearance:none;-moz-appearance:none;appearance:none;margin:3px 0;height:4px;border:none;background-color:#eee;color:#222;width:100%;transition:.5s linear}.frc-progress::-webkit-progress-bar{background:#eee}.frc-progress::-webkit-progress-value{background:#222}.frc-progress::-moz-progress-bar{background:#222}.frc-button{cursor:pointer;padding:2px 6px;background-color:#f1f1f1;border:1px solid transparent;text-align:center;font-weight:600;text-transform:none}.frc-button:focus{border:1px solid #333}.frc-button:hover{background-color:#ddd}.frc-captcha-solution{display:none}.frc-err-url{text-decoration:underline;font-size:.9em}.frc-rtl{direction:rtl}.frc-rtl .frc-content{margin:4px 0 0 6px}.frc-banner.frc-rtl{left:6px;right:auto}.dark.frc-captcha{color:#fff;background-color:#222;border-color:#333}.dark.frc-captcha *{color:#fff}.dark.frc-captcha button{background-color:#444}.dark .frc-icon{fill:#fff;stroke:#fff}.dark .frc-progress{background-color:#444}.dark .frc-progress::-webkit-progress-bar{background:#444}.dark .frc-progress::-webkit-progress-value{background:#ddd}.dark .frc-progress::-moz-progress-bar{background:#ddd}@keyframes frc-fade-in{from{opacity:0}to{opacity:1}}'; |
| 19 |
|
| 20 |
// This is not an enum to save some bytes in the output bundle. |
| 21 |
var SOLVER_TYPE_JS = 1; |
| 22 |
var CHALLENGE_SIZE_BYTES = 128; |
| 23 |
|
| 24 |
// @ts-ignore |
| 25 |
var loaderSVG = "<circle cx=\"12\" cy=\"12\" r=\"8\" stroke-width=\"3\" stroke-dasharray=\"15 10\" fill=\"none\" stroke-linecap=\"round\" transform=\"rotate(0 12 12)\"><animateTransform attributeName=\"transform\" type=\"rotate\" repeatCount=\"indefinite\" dur=\"0.9s\" values=\"0 12 12;360 12 12\"/></circle>"; |
| 26 |
var errorSVG = "<path d=\"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z\"/>"; |
| 27 |
/** |
| 28 |
* Base template used for all widget states |
| 29 |
* The reason we use raw string interpolation here is so we don't have to ship something like lit-html. |
| 30 |
*/ |
| 31 |
function getTemplate(fieldName, rtl, svgContent, svgAriaHidden, textContent, solutionString, buttonText) { |
| 32 |
var progress = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : false; |
| 33 |
var debugData = arguments.length > 8 ? arguments[8] : undefined; |
| 34 |
var additionalContainerClasses = arguments.length > 9 ? arguments[9] : undefined; |
| 35 |
return "<div class=\"frc-container".concat(additionalContainerClasses ? " " + additionalContainerClasses : "").concat(rtl ? " frc-rtl" : "", "\">\n<svg class=\"frc-icon\"").concat(svgAriaHidden ? ' aria-hidden="true"' : "", " role=\"img\" xmlns=\"http://www.w3.org/2000/svg\" height=\"32\" width=\"32\" viewBox=\"0 0 24 24\">").concat(svgContent, "</svg>\n<div class=\"frc-content\">\n <span class=\"frc-text\" ").concat(debugData ? "data-debug=\"".concat(debugData, "\"") : "", ">").concat(textContent, "</span>\n ").concat(buttonText ? "<button type=\"button\" class=\"frc-button\">".concat(buttonText, "</button>") : "", "\n ").concat(progress ? "<progress class=\"frc-progress\" value=\"0\">0%</progress>" : "", "\n</div>\n</div><span class=\"frc-banner").concat(rtl ? " frc-rtl" : "", "\"><a lang=\"en\" href=\"https://friendlycaptcha.com/\" rel=\"noopener\" target=\"_blank\"><b>Friendly</b>Captcha \u21D7</a></span>\n").concat(fieldName === "-" ? "" : "<input name=\"".concat(fieldName, "\" class=\"frc-captcha-solution\" type=\"hidden\" value=\"").concat(solutionString, "\">")); |
| 36 |
} |
| 37 |
/** |
| 38 |
* Used when the widget is ready to start solving. |
| 39 |
*/ |
| 40 |
function getReadyHTML(fieldName, l) { |
| 41 |
return getTemplate(fieldName, l.rtl, "<path d=\"M17,11c0.34,0,0.67,0.04,1,0.09V6.27L10.5,3L3,6.27v4.91c0,4.54,3.2,8.79,7.5,9.82c0.55-0.13,1.08-0.32,1.6-0.55 C11.41,19.47,11,18.28,11,17C11,13.69,13.69,11,17,11z\"/><path d=\"M17,13c-2.21,0-4,1.79-4,4c0,2.21,1.79,4,4,4s4-1.79,4-4C21,14.79,19.21,13,17,13z M17,14.38\"/>", true, l.text_ready, ".UNSTARTED", l.button_start, false); |
| 42 |
} |
| 43 |
/** |
| 44 |
* Used when the widget is retrieving a puzzle |
| 45 |
*/ |
| 46 |
function getFetchingHTML(fieldName, l) { |
| 47 |
return getTemplate(fieldName, l.rtl, loaderSVG, true, l.text_fetching, ".FETCHING", undefined, true); |
| 48 |
} |
| 49 |
/** |
| 50 |
* Used when the solver is running, displays a progress bar. |
| 51 |
*/ |
| 52 |
function getRunningHTML(fieldName, l) { |
| 53 |
return getTemplate(fieldName, l.rtl, loaderSVG, true, l.text_solving, ".UNFINISHED", undefined, true); |
| 54 |
} |
| 55 |
function getDoneHTML(fieldName, l, solution, data) { |
| 56 |
var timeData = "".concat(data.t.toFixed(0), "s (").concat((data.h / data.t * 0.001).toFixed(0), "K/s)").concat(data.solver === SOLVER_TYPE_JS ? " JS Fallback" : ""); |
| 57 |
return getTemplate(fieldName, l.rtl, "<title>".concat(l.text_completed_sr, "</title><path d=\"M12 1L3 5v6c0 5.55 3.84 10.74 9 12 5.16-1.26 9-6.45 9-12V5l-9-4zm-2 16l-4-4 1.41-1.41L10 14.17l6.59-6.59L18 9l-8 8z\"></path>"), false, l.text_completed, solution, undefined, false, timeData, "frc-success"); |
| 58 |
} |
| 59 |
function getExpiredHTML(fieldName, l) { |
| 60 |
return getTemplate(fieldName, l.rtl, errorSVG, true, l.text_expired, ".EXPIRED", l.button_restart); |
| 61 |
} |
| 62 |
function getErrorHTML(fieldName, l, errorDescription) { |
| 63 |
var recoverable = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true; |
| 64 |
var headless = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false; |
| 65 |
return getTemplate(fieldName, l.rtl, errorSVG, true, "<b>".concat(l.text_error, "</b><br>").concat(errorDescription), headless ? ".HEADLESS_ERROR" : ".ERROR", recoverable ? l.button_retry : undefined); |
| 66 |
} |
| 67 |
function findCaptchaElements() { |
| 68 |
var elements = document.querySelectorAll(".frc-captcha"); |
| 69 |
if (elements.length === 0) { |
| 70 |
console.warn("FriendlyCaptcha: No div was found with .frc-captcha class"); |
| 71 |
} |
| 72 |
return elements; |
| 73 |
} |
| 74 |
/** |
| 75 |
* Injects the style if no #frc-style element is already present |
| 76 |
* (to support custom stylesheets) |
| 77 |
*/ |
| 78 |
function injectStyle() { |
| 79 |
var styleNonce = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; |
| 80 |
if (!document.querySelector("#frc-style")) { |
| 81 |
var styleSheet = document.createElement("style"); |
| 82 |
styleSheet.id = "frc-style"; |
| 83 |
styleSheet.innerHTML = css; |
| 84 |
if (styleNonce) { |
| 85 |
styleSheet.setAttribute('nonce', styleNonce); |
| 86 |
} |
| 87 |
document.head.appendChild(styleSheet); |
| 88 |
} |
| 89 |
} |
| 90 |
/** |
| 91 |
* @param element parent element of friendlycaptcha |
| 92 |
* @param progress value between 0 and 1 |
| 93 |
*/ |
| 94 |
function updateProgressBar(element, data) { |
| 95 |
var p = element.querySelector(".frc-progress"); |
| 96 |
var perc = (data.i + 1) / data.n; |
| 97 |
if (p) { |
| 98 |
p.value = perc; |
| 99 |
p.innerText = (perc * 100).toFixed(1) + "%"; |
| 100 |
p.title = data.i + 1 + "/" + data.n + " (" + (data.h / data.t * 0.001).toFixed(0) + "K/s)"; |
| 101 |
} |
| 102 |
} |
| 103 |
/** |
| 104 |
* Traverses parent nodes until a <form> is found, returns null if not found. |
| 105 |
*/ |
| 106 |
function findParentFormElement(element) { |
| 107 |
while (element.tagName !== "FORM") { |
| 108 |
element = element.parentElement; |
| 109 |
if (!element) { |
| 110 |
return null; |
| 111 |
} |
| 112 |
} |
| 113 |
return element; |
| 114 |
} |
| 115 |
/** |
| 116 |
* Add listener to specified element that will only fire once on focus. |
| 117 |
*/ |
| 118 |
function executeOnceOnFocusInEvent(element, listener) { |
| 119 |
element.addEventListener("focusin", listener, { |
| 120 |
once: true, |
| 121 |
passive: true |
| 122 |
}); |
| 123 |
} |
| 124 |
|
| 125 |
// Adapted from the base64-arraybuffer package implementation |
| 126 |
// (https://github.com/niklasvh/base64-arraybuffer, MIT licensed) |
| 127 |
var CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; |
| 128 |
var EQ_CHAR = "=".charCodeAt(0); |
| 129 |
// Use a lookup table to find the index. |
| 130 |
var lookup = new Uint8Array(256); |
| 131 |
for (var i = 0; i < CHARS.length; i++) { |
| 132 |
lookup[CHARS.charCodeAt(i)] = i; |
| 133 |
} |
| 134 |
function encode(bytes) { |
| 135 |
var len = bytes.length; |
| 136 |
var base64 = ""; |
| 137 |
for (var _i = 0; _i < len; _i += 3) { |
| 138 |
var b0 = bytes[_i + 0]; |
| 139 |
var b1 = bytes[_i + 1]; |
| 140 |
var b2 = bytes[_i + 2]; |
| 141 |
// This temporary variable stops the NextJS 13 compiler from breaking this code in optimization. |
| 142 |
// See issue https://github.com/FriendlyCaptcha/friendly-challenge/issues/165 |
| 143 |
var t = ""; |
| 144 |
t += CHARS.charAt(b0 >>> 2); |
| 145 |
t += CHARS.charAt((b0 & 3) << 4 | b1 >>> 4); |
| 146 |
t += CHARS.charAt((b1 & 15) << 2 | b2 >>> 6); |
| 147 |
t += CHARS.charAt(b2 & 63); |
| 148 |
base64 += t; |
| 149 |
} |
| 150 |
if (len % 3 === 2) { |
| 151 |
base64 = base64.substring(0, base64.length - 1) + "="; |
| 152 |
} else if (len % 3 === 1) { |
| 153 |
base64 = base64.substring(0, base64.length - 2) + "=="; |
| 154 |
} |
| 155 |
return base64; |
| 156 |
} |
| 157 |
function decode(base64) { |
| 158 |
var len = base64.length; |
| 159 |
var bufferLength = len * 3 >>> 2; // * 0.75 |
| 160 |
if (base64.charCodeAt(len - 1) === EQ_CHAR) bufferLength--; |
| 161 |
if (base64.charCodeAt(len - 2) === EQ_CHAR) bufferLength--; |
| 162 |
var bytes = new Uint8Array(bufferLength); |
| 163 |
for (var _i2 = 0, p = 0; _i2 < len; _i2 += 4) { |
| 164 |
var encoded1 = lookup[base64.charCodeAt(_i2 + 0)]; |
| 165 |
var encoded2 = lookup[base64.charCodeAt(_i2 + 1)]; |
| 166 |
var encoded3 = lookup[base64.charCodeAt(_i2 + 2)]; |
| 167 |
var encoded4 = lookup[base64.charCodeAt(_i2 + 3)]; |
| 168 |
bytes[p++] = encoded1 << 2 | encoded2 >> 4; |
| 169 |
bytes[p++] = (encoded2 & 15) << 4 | encoded3 >> 2; |
| 170 |
bytes[p++] = (encoded3 & 3) << 6 | encoded4 & 63; |
| 171 |
} |
| 172 |
return bytes; |
| 173 |
} |
| 174 |
|
| 175 |
// Defensive init to make it easier to integrate with Gatsby, NextJS, and friends. |
| 176 |
var nav; |
| 177 |
var ua; |
| 178 |
if (typeof navigator !== "undefined" && typeof navigator.userAgent === "string") { |
| 179 |
nav = navigator; |
| 180 |
ua = nav.userAgent.toLowerCase(); |
| 181 |
} |
| 182 |
/** |
| 183 |
* Headless browser detection on the clientside is imperfect. One can modify any clientside code to disable or change this check, |
| 184 |
* and one can spoof whatever is checked here. However, that doesn't make it worthless: it's yet another hurdle for spammers and |
| 185 |
* it stops unsophisticated scripters from making any request whatsoever. |
| 186 |
*/ |
| 187 |
function isHeadless() { |
| 188 |
return ( |
| 189 |
//tell-tale bot signs |
| 190 |
ua.indexOf("headless") !== -1 || nav.appVersion.indexOf("Headless") !== -1 || ua.indexOf("bot") !== -1 || |
| 191 |
// http://www.useragentstring.com/pages/useragentstring.php?typ=Browser |
| 192 |
ua.indexOf("crawl") !== -1 || |
| 193 |
// Only IE5 has two distributions that has this on windows NT.. so yeah. |
| 194 |
nav.webdriver === true || !nav.language || nav.languages !== undefined && !nav.languages.length // IE 11 does not support NavigatorLanguage.languages https://developer.mozilla.org/en-US/docs/Web/API/NavigatorLanguage/languages |
| 195 |
); |
| 196 |
} |
| 197 |
|
| 198 |
/** |
| 199 |
* Maps a value between 0 and 255 to a difficulty threshold (as uint32) |
| 200 |
* Difficulty 0 maps to 99.99% probability of being right on the first attempt |
| 201 |
* Anything above 250 needs 2^32 tries on average to solve. |
| 202 |
* 150 to 180 seems reasonable |
| 203 |
*/ |
| 204 |
function difficultyToThreshold(value) { |
| 205 |
if (value > 255) { |
| 206 |
value = 255; |
| 207 |
} else if (value < 0) { |
| 208 |
value = 0; |
| 209 |
} |
| 210 |
return Math.pow(2, (255.999 - value) / 8.0) >>> 0; |
| 211 |
} |
| 212 |
var PUZZLE_EXPIRY_OFFSET = 13; |
| 213 |
var NUMBER_OF_PUZZLES_OFFSET = 14; |
| 214 |
var PUZZLE_DIFFICULTY_OFFSET = 15; |
| 215 |
function getPuzzleSolverInputs(puzzleBuffer, numPuzzles) { |
| 216 |
var startingPoints = []; |
| 217 |
for (var _i3 = 0; _i3 < numPuzzles; _i3++) { |
| 218 |
var input = new Uint8Array(CHALLENGE_SIZE_BYTES); |
| 219 |
input.set(puzzleBuffer); |
| 220 |
input[120] = _i3; |
| 221 |
startingPoints.push(input); |
| 222 |
} |
| 223 |
return startingPoints; |
| 224 |
} |
| 225 |
function decodeBase64Puzzle(base64Puzzle) { |
| 226 |
var parts = base64Puzzle.split("."); |
| 227 |
var puzzle = parts[1]; |
| 228 |
var arr = decode(puzzle); |
| 229 |
return { |
| 230 |
signature: parts[0], |
| 231 |
base64: puzzle, |
| 232 |
buffer: arr, |
| 233 |
n: arr[NUMBER_OF_PUZZLES_OFFSET], |
| 234 |
threshold: difficultyToThreshold(arr[PUZZLE_DIFFICULTY_OFFSET]), |
| 235 |
expiry: arr[PUZZLE_EXPIRY_OFFSET] * 300000 |
| 236 |
}; |
| 237 |
} |
| 238 |
function getPuzzle(urlsSeparatedByComma, siteKey, lang) { |
| 239 |
return new Promise(function ($return, $error) { |
| 240 |
var urls; |
| 241 |
urls = urlsSeparatedByComma.split(","); |
| 242 |
var $Loop_4_trampoline, $Loop_4_local; |
| 243 |
function $Loop_4_step() { |
| 244 |
var _$Loop_4_local = $Loop_4_local(), |
| 245 |
_$Loop_4_local2 = _slicedToArray(_$Loop_4_local, 1), |
| 246 |
i = _$Loop_4_local2[0]; |
| 247 |
i++; |
| 248 |
return $Loop_4.bind(this, i); |
| 249 |
} |
| 250 |
function $Loop_4(i) { |
| 251 |
$Loop_4_local = function $Loop_4_local() { |
| 252 |
return [i]; |
| 253 |
}; |
| 254 |
if (i < urls.length) { |
| 255 |
var $Try_1_Post = function $Try_1_Post() { |
| 256 |
try { |
| 257 |
return $Loop_4_step; |
| 258 |
} catch ($boundEx) { |
| 259 |
return $error($boundEx); |
| 260 |
} |
| 261 |
}; |
| 262 |
var $Try_1_Catch = function $Try_1_Catch(e) { |
| 263 |
try { |
| 264 |
{ |
| 265 |
console.error("[FRC Fetch]:", e); |
| 266 |
var err; |
| 267 |
err = new Error("".concat(lang.text_fetch_error, " <a class=\"frc-err-url\" href=\"").concat(urls[i], "\">").concat(urls[i], "</a>")); |
| 268 |
err.rawError = e; |
| 269 |
throw err; |
| 270 |
} |
| 271 |
} catch ($boundEx) { |
| 272 |
return $error($boundEx); |
| 273 |
} |
| 274 |
}; |
| 275 |
try { |
| 276 |
var response; |
| 277 |
return Promise.resolve(fetchAndRetryWithBackoff(urls[i] + "?sitekey=" + siteKey, { |
| 278 |
headers: [["x-frc-client", "js-0.9.19"]], |
| 279 |
mode: "cors" |
| 280 |
}, 2)).then(function ($await_7) { |
| 281 |
try { |
| 282 |
var $If_6 = function $If_6() { |
| 283 |
return $Try_1_Post(); |
| 284 |
}; |
| 285 |
response = $await_7; |
| 286 |
if (response.ok) { |
| 287 |
var json; |
| 288 |
return Promise.resolve(response.json()).then(function ($await_8) { |
| 289 |
try { |
| 290 |
json = $await_8; |
| 291 |
return $return(json.data.puzzle); |
| 292 |
} catch ($boundEx) { |
| 293 |
return $Try_1_Catch($boundEx); |
| 294 |
} |
| 295 |
}, $Try_1_Catch); |
| 296 |
} else { |
| 297 |
var _json; |
| 298 |
var $Try_2_Post = function () { |
| 299 |
try { |
| 300 |
if (_json && _json.errors && _json.errors[0] === "endpoint_not_enabled") { |
| 301 |
throw Error("Endpoint not allowed (".concat(response.status, ")")); |
| 302 |
} |
| 303 |
if (i === urls.length - 1) { |
| 304 |
throw Error("Response status ".concat(response.status, " ").concat(response.statusText, " ").concat(_json ? _json.errors : "")); |
| 305 |
} |
| 306 |
return $If_6.call(this); |
| 307 |
} catch ($boundEx) { |
| 308 |
return $Try_1_Catch($boundEx); |
| 309 |
} |
| 310 |
}.bind(this); |
| 311 |
var $Try_2_Catch = function $Try_2_Catch(e) { |
| 312 |
try { |
| 313 |
return $Try_2_Post(); |
| 314 |
} catch ($boundEx) { |
| 315 |
return $Try_1_Catch($boundEx); |
| 316 |
} |
| 317 |
} /* Do nothing, the error is not valid JSON */; |
| 318 |
try { |
| 319 |
return Promise.resolve(response.json()).then(function ($await_9) { |
| 320 |
try { |
| 321 |
_json = $await_9; |
| 322 |
return $Try_2_Post(); |
| 323 |
} catch ($boundEx) { |
| 324 |
return $Try_2_Catch($boundEx); |
| 325 |
} |
| 326 |
}, $Try_2_Catch); |
| 327 |
} catch (e) { |
| 328 |
$Try_2_Catch(e); |
| 329 |
} |
| 330 |
} |
| 331 |
return $If_6.call(this); |
| 332 |
} catch ($boundEx) { |
| 333 |
return $Try_1_Catch($boundEx); |
| 334 |
} |
| 335 |
}.bind(this), $Try_1_Catch); |
| 336 |
} catch (e) { |
| 337 |
$Try_1_Catch(e); |
| 338 |
} |
| 339 |
} else return [1]; |
| 340 |
} |
| 341 |
return ($Loop_4_trampoline = function (q) { |
| 342 |
while (q) { |
| 343 |
if (q.then) return void q.then($Loop_4_trampoline, $error); |
| 344 |
try { |
| 345 |
if (q.pop) { |
| 346 |
if (q.length) return q.pop() ? $Loop_4_exit.call(this) : q;else q = $Loop_4_step; |
| 347 |
} else q = q.call(this); |
| 348 |
} catch (_exception) { |
| 349 |
return $error(_exception); |
| 350 |
} |
| 351 |
} |
| 352 |
}.bind(this))($Loop_4.bind(this, 0)); |
| 353 |
function $Loop_4_exit() { |
| 354 |
// This code should never be reached. |
| 355 |
return $error(Error("Internal error")); |
| 356 |
} |
| 357 |
}); |
| 358 |
} |
| 359 |
/** |
| 360 |
* Retries given request with exponential backoff (starting with 1000ms delay, multiplying by 4 every time) |
| 361 |
* @param url Request (can be string url) to fetch |
| 362 |
* @param opts Options for fetch |
| 363 |
* @param n Number of times to attempt before giving up. |
| 364 |
*/ |
| 365 |
function fetchAndRetryWithBackoff(url, opts, n) { |
| 366 |
return new Promise(function ($return, $error) { |
| 367 |
var time = 1000; |
| 368 |
return $return(fetch(url, opts).catch(function (error) { |
| 369 |
return new Promise(function ($return, $error) { |
| 370 |
if (n === 0) return $error(error); |
| 371 |
return Promise.resolve(new Promise(function (r) { |
| 372 |
return setTimeout(r, time); |
| 373 |
})).then(function ($await_10) { |
| 374 |
try { |
| 375 |
time *= 4; |
| 376 |
return $return(fetchAndRetryWithBackoff(url, opts, n - 1)); |
| 377 |
} catch ($boundEx) { |
| 378 |
return $error($boundEx); |
| 379 |
} |
| 380 |
}, $error); |
| 381 |
}); |
| 382 |
})); |
| 383 |
}); |
| 384 |
} |
| 385 |
|
| 386 |
// English |
| 387 |
var LANG_EN = { |
| 388 |
text_init: "Initializing...", |
| 389 |
text_ready: "Anti-Robot Verification", |
| 390 |
button_start: "Click to start verification", |
| 391 |
text_fetching: "Fetching Challenge", |
| 392 |
text_solving: "Verifying you are human...", |
| 393 |
text_completed: "I am human", |
| 394 |
text_completed_sr: "Automatic spam check completed", |
| 395 |
text_expired: "Anti-Robot verification expired", |
| 396 |
button_restart: "Restart", |
| 397 |
text_error: "Verification failed", |
| 398 |
button_retry: "Retry", |
| 399 |
text_fetch_error: "Failed to connect to" |
| 400 |
}; |
| 401 |
// French |
| 402 |
var LANG_FR = { |
| 403 |
text_init: "Chargement...", |
| 404 |
text_ready: "Vérification Anti-Robot", |
| 405 |
button_start: "Clique ici pour vérifier", |
| 406 |
text_fetching: "Chargement du défi", |
| 407 |
text_solving: "Nous vérifions que vous n'êtes pas un robot...", |
| 408 |
text_completed: "Je ne suis pas un robot", |
| 409 |
text_completed_sr: "Vérification automatique des spams terminée", |
| 410 |
text_expired: "Vérification anti-robot expirée", |
| 411 |
button_restart: "Redémarrer", |
| 412 |
text_error: "Échec de la vérification", |
| 413 |
button_retry: "Recommencer", |
| 414 |
text_fetch_error: "Problème de connexion avec" |
| 415 |
}; |
| 416 |
// German |
| 417 |
var LANG_DE = { |
| 418 |
text_init: "Initialisierung...", |
| 419 |
text_ready: "Anti-Roboter-Verifizierung", |
| 420 |
button_start: "Hier klicken", |
| 421 |
text_fetching: "Herausforderung laden...", |
| 422 |
text_solving: "Verifizierung, dass Sie ein Mensch sind...", |
| 423 |
text_completed: "Ich bin ein Mensch", |
| 424 |
text_completed_sr: "Automatische Spamprüfung abgeschlossen", |
| 425 |
text_expired: "Verifizierung abgelaufen", |
| 426 |
button_restart: "Erneut starten", |
| 427 |
text_error: "Verifizierung fehlgeschlagen", |
| 428 |
button_retry: "Erneut versuchen", |
| 429 |
text_fetch_error: "Verbindungsproblem mit" |
| 430 |
}; |
| 431 |
// Dutch |
| 432 |
var LANG_NL = { |
| 433 |
text_init: "Initializeren...", |
| 434 |
text_ready: "Anti-robotverificatie", |
| 435 |
button_start: "Klik om te starten", |
| 436 |
text_fetching: "Aan het laden...", |
| 437 |
text_solving: "Anti-robotverificatie bezig...", |
| 438 |
text_completed: "Ik ben een mens", |
| 439 |
text_completed_sr: "Automatische anti-spamcheck voltooid", |
| 440 |
text_expired: "Verificatie verlopen", |
| 441 |
button_restart: "Opnieuw starten", |
| 442 |
text_error: "Verificatie mislukt", |
| 443 |
button_retry: "Opnieuw proberen", |
| 444 |
text_fetch_error: "Verbinding mislukt met" |
| 445 |
}; |
| 446 |
// Italian |
| 447 |
var LANG_IT = { |
| 448 |
text_init: "Inizializzazione...", |
| 449 |
text_ready: "Verifica Anti-Robot", |
| 450 |
button_start: "Clicca per iniziare", |
| 451 |
text_fetching: "Caricamento...", |
| 452 |
text_solving: "Verificando che sei umano...", |
| 453 |
text_completed: "Non sono un robot", |
| 454 |
text_completed_sr: "Controllo automatico dello spam completato", |
| 455 |
text_expired: "Verifica Anti-Robot scaduta", |
| 456 |
button_restart: "Ricomincia", |
| 457 |
text_error: "Verifica fallita", |
| 458 |
button_retry: "Riprova", |
| 459 |
text_fetch_error: "Problema di connessione con" |
| 460 |
}; |
| 461 |
// Portuguese |
| 462 |
var LANG_PT = { |
| 463 |
text_init: "Inicializando...", |
| 464 |
text_ready: "Verificação Anti-Robô", |
| 465 |
button_start: "Clique para iniciar verificação", |
| 466 |
text_fetching: "Carregando...", |
| 467 |
text_solving: "Verificando se você é humano...", |
| 468 |
text_completed: "Eu sou humano", |
| 469 |
text_completed_sr: "Verificação automática de spam concluída", |
| 470 |
text_expired: "Verificação Anti-Robô expirada", |
| 471 |
button_restart: "Reiniciar", |
| 472 |
text_error: "Verificação falhou", |
| 473 |
button_retry: "Tentar novamente", |
| 474 |
text_fetch_error: "Falha de conexão com" |
| 475 |
}; |
| 476 |
// Spanish |
| 477 |
var LANG_ES = { |
| 478 |
text_init: "Inicializando...", |
| 479 |
text_ready: "Verificación Anti-Robot", |
| 480 |
button_start: "Haga clic para iniciar la verificación", |
| 481 |
text_fetching: "Cargando desafío", |
| 482 |
text_solving: "Verificando que eres humano...", |
| 483 |
text_completed: "Soy humano", |
| 484 |
text_completed_sr: "Verificación automática de spam completada", |
| 485 |
text_expired: "Verificación Anti-Robot expirada", |
| 486 |
button_restart: "Reiniciar", |
| 487 |
text_error: "Ha fallado la verificación", |
| 488 |
button_retry: "Intentar de nuevo", |
| 489 |
text_fetch_error: "Error al conectarse a" |
| 490 |
}; |
| 491 |
// Catalan |
| 492 |
var LANG_CA = { |
| 493 |
text_init: "Inicialitzant...", |
| 494 |
text_ready: "Verificació Anti-Robot", |
| 495 |
button_start: "Fes clic per començar la verificació", |
| 496 |
text_fetching: "Carregant repte", |
| 497 |
text_solving: "Verificant que ets humà...", |
| 498 |
text_completed: "Soc humà", |
| 499 |
text_completed_sr: "Verificació automàtica de correu brossa completada", |
| 500 |
text_expired: "La verificació Anti-Robot ha expirat", |
| 501 |
button_restart: "Reiniciar", |
| 502 |
text_error: "Ha fallat la verificació", |
| 503 |
button_retry: "Tornar a provar", |
| 504 |
text_fetch_error: "Error connectant a" |
| 505 |
}; |
| 506 |
// Japanese |
| 507 |
var LANG_JA = { |
| 508 |
text_init: "開始しています...", |
| 509 |
text_ready: "アンチロボット認証", |
| 510 |
button_start: "クリックして認証を開始", |
| 511 |
text_fetching: "ロードしています", |
| 512 |
text_solving: "認証中...", |
| 513 |
text_completed: "私はロボットではありません", |
| 514 |
text_completed_sr: "自動スパムチェックが完了しました", |
| 515 |
text_expired: "認証の期限が切れています", |
| 516 |
button_restart: "再度認証を行う", |
| 517 |
text_error: "認証にエラーが発生しました", |
| 518 |
button_retry: "再度認証を行う", |
| 519 |
text_fetch_error: "接続ができませんでした" |
| 520 |
}; |
| 521 |
// Danish |
| 522 |
var LANG_DA = { |
| 523 |
text_init: "Aktiverer...", |
| 524 |
text_ready: "Jeg er ikke en robot", |
| 525 |
button_start: "Klik for at starte verifikationen", |
| 526 |
text_fetching: "Henter data", |
| 527 |
text_solving: "Kontrollerer at du er et menneske...", |
| 528 |
text_completed: "Jeg er et menneske.", |
| 529 |
text_completed_sr: "Automatisk spamkontrol gennemført", |
| 530 |
text_expired: "Verifikationen kunne ikke fuldføres", |
| 531 |
button_restart: "Genstart", |
| 532 |
text_error: "Bekræftelse mislykkedes", |
| 533 |
button_retry: "Prøv igen", |
| 534 |
text_fetch_error: "Forbindelsen mislykkedes" |
| 535 |
}; |
| 536 |
// Russian |
| 537 |
var LANG_RU = { |
| 538 |
text_init: "Инициализация...", |
| 539 |
text_ready: "АнтиРобот проверка", |
| 540 |
button_start: "Нажмите, чтобы начать проверку", |
| 541 |
text_fetching: "Получаю задачу", |
| 542 |
text_solving: "Проверяю, что вы человек...", |
| 543 |
text_completed: "Я человек", |
| 544 |
text_completed_sr: "Aвтоматическая проверка на спам завершена", |
| 545 |
text_expired: "Срок АнтиРоботной проверки истёк", |
| 546 |
button_restart: "Начать заново", |
| 547 |
text_error: "Ошибка проверки", |
| 548 |
button_retry: "Повторить ещё раз", |
| 549 |
text_fetch_error: "Ошибка подключения" |
| 550 |
}; |
| 551 |
// Swedish |
| 552 |
var LANG_SV = { |
| 553 |
text_init: "Aktiverar...", |
| 554 |
text_ready: "Jag är inte en robot", |
| 555 |
button_start: "Klicka för att verifiera", |
| 556 |
text_fetching: "Hämtar data", |
| 557 |
text_solving: "Kontrollerar att du är människa...", |
| 558 |
text_completed: "Jag är en människa", |
| 559 |
text_completed_sr: "Automatisk spamkontroll slutförd", |
| 560 |
text_expired: "Anti-robot-verifieringen har löpt ut", |
| 561 |
button_restart: "Börja om", |
| 562 |
text_error: "Verifiering kunde inte slutföras", |
| 563 |
button_retry: "Omstart", |
| 564 |
text_fetch_error: "Verifiering misslyckades" |
| 565 |
}; |
| 566 |
// Turkish |
| 567 |
var LANG_TR = { |
| 568 |
text_init: "Başlatılıyor...", |
| 569 |
text_ready: "Anti-Robot Doğrulaması", |
| 570 |
button_start: "Doğrulamayı başlatmak için tıklayın", |
| 571 |
text_fetching: "Yükleniyor", |
| 572 |
text_solving: "Robot olmadığınız doğrulanıyor...", |
| 573 |
text_completed: "Ben bir insanım", |
| 574 |
text_completed_sr: "Otomatik spam kontrolü tamamlandı", |
| 575 |
text_expired: "Anti-Robot doğrulamasının süresi doldu", |
| 576 |
button_restart: "Yeniden başlat", |
| 577 |
text_error: "Doğrulama başarısız oldu", |
| 578 |
button_retry: "Tekrar dene", |
| 579 |
text_fetch_error: "Bağlantı başarısız oldu" |
| 580 |
}; |
| 581 |
// Greek |
| 582 |
var LANG_EL = { |
| 583 |
text_init: "Προετοιμασία...", |
| 584 |
text_ready: "Anti-Robot Επαλήθευση", |
| 585 |
button_start: " Κάντε κλικ για να ξεκινήσει η επαλήθευση", |
| 586 |
text_fetching: " Λήψη πρόκλησης", |
| 587 |
text_solving: " Επιβεβαίωση ανθρώπου...", |
| 588 |
text_completed: "Είμαι άνθρωπος", |
| 589 |
text_completed_sr: " Ο αυτόματος έλεγχος ανεπιθύμητου περιεχομένου ολοκληρώθηκε", |
| 590 |
text_expired: " Η επαλήθευση Anti-Robot έληξε", |
| 591 |
button_restart: " Επανεκκίνηση", |
| 592 |
text_error: " Η επαλήθευση απέτυχε", |
| 593 |
button_retry: " Δοκιμάστε ξανά", |
| 594 |
text_fetch_error: " Αποτυχία σύνδεσης με" |
| 595 |
}; |
| 596 |
// Ukrainian |
| 597 |
var LANG_UK = { |
| 598 |
text_init: "Ініціалізація...", |
| 599 |
text_ready: "Антиробот верифікація", |
| 600 |
button_start: "Натисніть, щоб розпочати верифікацію", |
| 601 |
text_fetching: "З’єднання", |
| 602 |
text_solving: "Перевірка, що ви не робот...", |
| 603 |
text_completed: "Я не робот", |
| 604 |
text_completed_sr: "Автоматична перевірка спаму завершена", |
| 605 |
text_expired: "Час вичерпано", |
| 606 |
button_restart: "Почати знову", |
| 607 |
text_error: "Верифікація не вдалась", |
| 608 |
button_retry: "Спробувати знову", |
| 609 |
text_fetch_error: "Не вдалось з’єднатись" |
| 610 |
}; |
| 611 |
// Bulgarian |
| 612 |
var LANG_BG = { |
| 613 |
text_init: "Инициализиране...", |
| 614 |
text_ready: "Анти-робот проверка", |
| 615 |
button_start: "Щракнете, за да започнете проверката", |
| 616 |
text_fetching: "Предизвикателство", |
| 617 |
text_solving: "Проверяваме дали си човек...", |
| 618 |
text_completed: "Аз съм човек", |
| 619 |
text_completed_sr: "Автоматичната проверка за спам е завършена", |
| 620 |
text_expired: "Анти-Робот проверката изтече", |
| 621 |
button_restart: "Рестартирайте", |
| 622 |
text_error: "Неуспешна проверка", |
| 623 |
button_retry: "Опитайте пак", |
| 624 |
text_fetch_error: "Неуспешно свързване с" |
| 625 |
}; |
| 626 |
// Czech |
| 627 |
var LANG_CS = { |
| 628 |
text_init: "Inicializace...", |
| 629 |
text_ready: "Ověření proti robotům", |
| 630 |
button_start: "Klikněte pro ověření", |
| 631 |
text_fetching: "Problém při načítání", |
| 632 |
text_solving: "Ověření, že jste člověk...", |
| 633 |
text_completed: "Jsem člověk", |
| 634 |
text_completed_sr: "Automatická kontrola spamu dokončena", |
| 635 |
text_expired: "Ověření proti robotům vypršelo", |
| 636 |
button_restart: "Restartovat", |
| 637 |
text_error: "Ověření se nezdařilo", |
| 638 |
button_retry: "Zkusit znovu", |
| 639 |
text_fetch_error: "Připojení se nezdařilo" |
| 640 |
}; |
| 641 |
// Slovak |
| 642 |
var LANG_SK = { |
| 643 |
text_init: "Inicializácia...", |
| 644 |
text_ready: "Overenie proti robotom", |
| 645 |
button_start: "Kliknite pre overenie", |
| 646 |
text_fetching: "Problém pri načítaní", |
| 647 |
text_solving: "Overenie, že ste človek...", |
| 648 |
text_completed: "Som človek", |
| 649 |
text_completed_sr: "Automatická kontrola spamu dokončená", |
| 650 |
text_expired: "Overenie proti robotom vypršalo", |
| 651 |
button_restart: "Reštartovať", |
| 652 |
text_error: "Overenie sa nepodarilo", |
| 653 |
button_retry: "Skúsiť znova", |
| 654 |
text_fetch_error: "Pripojenie sa nepodarilo" |
| 655 |
}; |
| 656 |
// Norwegian |
| 657 |
var LANG_NO = { |
| 658 |
text_init: " Aktiverer...", |
| 659 |
text_ready: "Jeg er ikke en robot", |
| 660 |
button_start: "Klikk for å starte verifiseringen", |
| 661 |
text_fetching: "Henter data", |
| 662 |
text_solving: "Sjekker at du er et menneske...", |
| 663 |
text_completed: "Jeg er et menneske", |
| 664 |
text_completed_sr: "Automatisk spam-sjekk fullført", |
| 665 |
text_expired: "Verifisering kunne ikke fullføres", |
| 666 |
button_restart: "Omstart", |
| 667 |
text_error: "Bekreftelsen mislyktes", |
| 668 |
button_retry: "Prøv på nytt", |
| 669 |
text_fetch_error: "Tilkoblingen mislyktes" |
| 670 |
}; |
| 671 |
// Finnish |
| 672 |
var LANG_FI = { |
| 673 |
text_init: "Aktivoidaan...", |
| 674 |
text_ready: "En ole robotti", |
| 675 |
button_start: "Aloita vahvistus klikkaamalla", |
| 676 |
text_fetching: "Haetaan tietoja", |
| 677 |
text_solving: "Tarkistaa, että olet ihminen...", |
| 678 |
text_completed: "Olen ihminen", |
| 679 |
text_completed_sr: "Automaattinen roskapostin tarkistus suoritettu", |
| 680 |
text_expired: "Vahvistusta ei voitu suorittaa loppuun", |
| 681 |
button_restart: "Uudelleenkäynnistys", |
| 682 |
text_error: "Vahvistus epäonnistui", |
| 683 |
button_retry: "Yritä uudelleen", |
| 684 |
text_fetch_error: "Yhteys epäonnistui" |
| 685 |
}; |
| 686 |
// Latvian |
| 687 |
var LANG_LV = { |
| 688 |
text_init: "Notiek inicializēšana...", |
| 689 |
text_ready: "Verifikācija, ka neesat robots", |
| 690 |
button_start: "Noklikšķiniet, lai sāktu verifikāciju", |
| 691 |
text_fetching: "Notiek drošības uzdevuma izgūšana", |
| 692 |
text_solving: "Notiek pārbaude, vai esat cilvēks...", |
| 693 |
text_completed: "Es esmu cilvēks", |
| 694 |
text_completed_sr: "Automātiska surogātpasta pārbaude pabeigta", |
| 695 |
text_expired: "Verifikācijas, ka neesat robots, derīgums beidzies", |
| 696 |
button_restart: "Restartēt", |
| 697 |
text_error: "Verifikācija neizdevās", |
| 698 |
button_retry: "Mēģināt vēlreiz", |
| 699 |
text_fetch_error: "Neizdevās izveidot savienojumu ar" |
| 700 |
}; |
| 701 |
// Lithuanian |
| 702 |
var LANG_LT = { |
| 703 |
text_init: "Inicijuojama...", |
| 704 |
text_ready: "Patikrinimas, ar nesate robotas", |
| 705 |
button_start: "Spustelėkite patikrinimui pradėti", |
| 706 |
text_fetching: "Gavimo iššūkis", |
| 707 |
text_solving: "Tikrinama, ar esate žmogus...", |
| 708 |
text_completed: "Esu žmogus", |
| 709 |
text_completed_sr: "Automatinė patikra dėl pašto šiukšlių atlikta", |
| 710 |
text_expired: "Patikrinimas, ar nesate robotas, baigė galioti", |
| 711 |
button_restart: "Pradėti iš naujo", |
| 712 |
text_error: "Patikrinimas nepavyko", |
| 713 |
button_retry: "Kartoti", |
| 714 |
text_fetch_error: "Nepavyko prisijungti prie" |
| 715 |
}; |
| 716 |
// Polish |
| 717 |
var LANG_PL = { |
| 718 |
text_init: "Inicjowanie...", |
| 719 |
text_ready: "Weryfikacja antybotowa", |
| 720 |
button_start: "Kliknij, aby rozpocząć weryfikację", |
| 721 |
text_fetching: "Pobieranie", |
| 722 |
text_solving: "Weryfikacja, czy nie jesteś robotem...", |
| 723 |
text_completed: "Nie jestem robotem", |
| 724 |
text_completed_sr: "Zakończono automatyczne sprawdzanie spamu", |
| 725 |
text_expired: "Weryfikacja antybotowa wygasła", |
| 726 |
button_restart: "Uruchom ponownie", |
| 727 |
text_error: "Weryfikacja nie powiodła się", |
| 728 |
button_retry: "Spróbuj ponownie", |
| 729 |
text_fetch_error: "Nie udało się połączyć z" |
| 730 |
}; |
| 731 |
// Estonian |
| 732 |
var LANG_ET = { |
| 733 |
text_init: "Initsialiseerimine...", |
| 734 |
text_ready: "Robotivastane kinnitus", |
| 735 |
button_start: "Kinnitamisega alustamiseks klõpsake", |
| 736 |
text_fetching: "Väljakutse toomine", |
| 737 |
text_solving: "Kinnitatakse, et sa oled inimene...", |
| 738 |
text_completed: "Ma olen inimene", |
| 739 |
text_completed_sr: "Automaatne rämpsposti kontroll on lõpetatud", |
| 740 |
text_expired: "Robotivastane kinnitus aegus", |
| 741 |
button_restart: "Taaskäivita", |
| 742 |
text_error: "Kinnitamine nurjus", |
| 743 |
button_retry: "Proovi uuesti", |
| 744 |
text_fetch_error: "Ühenduse loomine nurjus" |
| 745 |
}; |
| 746 |
// Croatian |
| 747 |
var LANG_HR = { |
| 748 |
text_init: "Početno postavljanje...", |
| 749 |
text_ready: "Provjera protiv robota", |
| 750 |
button_start: "Kliknite za početak provjere", |
| 751 |
text_fetching: "Dohvaćanje izazova", |
| 752 |
text_solving: "Provjeravamo jeste li čovjek...", |
| 753 |
text_completed: "Nisam robot", |
| 754 |
text_completed_sr: "Automatska provjera je završena", |
| 755 |
text_expired: "Vrijeme za provjeru protiv robota je isteklo", |
| 756 |
button_restart: "Osvježi", |
| 757 |
text_error: "Provjera nije uspjlela", |
| 758 |
button_retry: " Ponovo pokreni", |
| 759 |
text_fetch_error: "Nije moguće uspostaviti vezu" |
| 760 |
}; |
| 761 |
// Serbian |
| 762 |
var LANG_SR = { |
| 763 |
text_init: "Pokretanje...", |
| 764 |
text_ready: "Anti-Robot Verifikacija", |
| 765 |
button_start: "Kliknite da biste započeli verifikaciju", |
| 766 |
text_fetching: "Učitavanje izazova", |
| 767 |
text_solving: "Verifikacija da ste čovek...", |
| 768 |
text_completed: "Ja sam čovek", |
| 769 |
text_completed_sr: "Automatska provera neželjene pošte je završena", |
| 770 |
text_expired: "Anti-Robot verifikacija je istekla", |
| 771 |
button_restart: "Ponovo pokrenuti", |
| 772 |
text_error: "Verifikacija nije uspela", |
| 773 |
button_retry: "Pokušajte ponovo", |
| 774 |
text_fetch_error: "Neuspelo povezivanje sa..." |
| 775 |
}; |
| 776 |
// Slovenian |
| 777 |
var LANG_SL = { |
| 778 |
text_init: "Inicializiranje...", |
| 779 |
text_ready: "Preverjanje robotov", |
| 780 |
button_start: "Kliknite za začetek preverjanja", |
| 781 |
text_fetching: "Prenašanje izziva", |
| 782 |
text_solving: "Preverjamo, ali ste človek", |
| 783 |
text_completed: "Nisem robot", |
| 784 |
text_completed_sr: "Avtomatsko preverjanje je zaključeno", |
| 785 |
text_expired: "Preverjanje robotov je poteklo", |
| 786 |
button_restart: "Osveži", |
| 787 |
text_error: "Preverjanje ni uspelo", |
| 788 |
button_retry: "Poskusi ponovno", |
| 789 |
text_fetch_error: "Povezave ni bilo mogoče vzpostaviti" |
| 790 |
}; |
| 791 |
// Hungarian |
| 792 |
var LANG_HU = { |
| 793 |
text_init: "Inicializálás...", |
| 794 |
text_ready: "Robotellenes ellenőrzés", |
| 795 |
button_start: "Kattintson az ellenőrzés megkezdéséhez", |
| 796 |
text_fetching: "Feladvány lekérése", |
| 797 |
text_solving: "Annak igazolása, hogy Ön nem robot...", |
| 798 |
text_completed: "Nem vagyok robot", |
| 799 |
text_completed_sr: "Automatikus spam ellenőrzés befejeződött", |
| 800 |
text_expired: "Robotellenes ellenőrzés lejárt", |
| 801 |
button_restart: "Újraindítás", |
| 802 |
text_error: "Az ellenőrzés nem sikerült", |
| 803 |
button_retry: "Próbálja újra", |
| 804 |
text_fetch_error: "Nem sikerült csatlakozni" |
| 805 |
}; |
| 806 |
// Romanian |
| 807 |
var LANG_RO = { |
| 808 |
text_init: "Se inițializează...", |
| 809 |
text_ready: "Verificare anti-robot", |
| 810 |
button_start: "Click pentru a începe verificarea", |
| 811 |
text_fetching: "Downloading", |
| 812 |
text_solving: "Verificare că ești om...", |
| 813 |
text_completed: "Sunt om", |
| 814 |
text_completed_sr: "Verificarea automată a spam-ului a fost finalizată", |
| 815 |
text_expired: "Verificarea anti-robot a expirat", |
| 816 |
button_restart: "Restart", |
| 817 |
text_error: "Verificare eșuată", |
| 818 |
button_retry: "Reîncearcă", |
| 819 |
text_fetch_error: "Nu s-a putut conecta" |
| 820 |
}; |
| 821 |
// Chinese |
| 822 |
var LANG_ZH = { |
| 823 |
text_init: "初始化中……", |
| 824 |
text_ready: "人机验证", |
| 825 |
button_start: "点击开始", |
| 826 |
text_fetching: "正在加载", |
| 827 |
text_solving: "人机校验中……", |
| 828 |
text_completed: "我不是机器人", |
| 829 |
text_completed_sr: "人机验证完成", |
| 830 |
text_expired: "验证已过期", |
| 831 |
button_restart: "重新开始", |
| 832 |
text_error: "校验失败", |
| 833 |
button_retry: "重试", |
| 834 |
text_fetch_error: "无法连接到" |
| 835 |
}; |
| 836 |
// Traditional Chinese |
| 837 |
var LANG_ZH_TW = { |
| 838 |
text_init: "正在初始化……", |
| 839 |
text_ready: "反機器人驗證", |
| 840 |
button_start: "點擊開始驗證", |
| 841 |
text_fetching: "載入中", |
| 842 |
text_solving: "反機器人驗證中……", |
| 843 |
text_completed: "我不是機器人", |
| 844 |
text_completed_sr: "驗證完成", |
| 845 |
text_expired: "驗證超時", |
| 846 |
button_restart: "重新開始", |
| 847 |
text_error: "驗證失敗", |
| 848 |
button_retry: "重試", |
| 849 |
text_fetch_error: "無法連線到" |
| 850 |
}; |
| 851 |
// Vietnamese |
| 852 |
var LANG_VI = { |
| 853 |
text_init: "Đang khởi tạo...", |
| 854 |
text_ready: "Xác minh chống Robot", |
| 855 |
button_start: "Bấm vào đây để xác minh", |
| 856 |
text_fetching: "Tìm nạp và xử lý thử thách", |
| 857 |
text_solving: "Xác minh bạn là người...", |
| 858 |
text_completed: "Bạn là con người", |
| 859 |
text_completed_sr: "Xác minh hoàn tất", |
| 860 |
text_expired: "Xác minh đã hết hạn", |
| 861 |
button_restart: "Khởi động lại", |
| 862 |
text_error: "Xác minh thất bại", |
| 863 |
button_retry: "Thử lại", |
| 864 |
text_fetch_error: "Không kết nối được" |
| 865 |
}; |
| 866 |
// Hebrew |
| 867 |
var LANG_HE = { |
| 868 |
text_init: "בביצוע...", |
| 869 |
text_ready: "אימות אנוש", |
| 870 |
button_start: "צריך ללחוץ להתחלת האימות", |
| 871 |
text_fetching: "אתגר המענה בהכנה", |
| 872 |
text_solving: "מתבצע אימות אנוש...", |
| 873 |
text_completed: "אני לא רובוט", |
| 874 |
text_completed_sr: "בדיקת הספאם האוטומטית הסתיימה", |
| 875 |
text_expired: "פג תוקף אימות האנוש", |
| 876 |
button_restart: "להתחיל שוב", |
| 877 |
text_error: "אימות האנוש נכשל", |
| 878 |
button_retry: "לנסות שוב", |
| 879 |
text_fetch_error: "נכשל החיבור אל", |
| 880 |
rtl: true |
| 881 |
}; |
| 882 |
// Thai |
| 883 |
var LANG_TH = { |
| 884 |
text_init: "การเริ่มต้น...", |
| 885 |
text_ready: " การตรวจสอบต่อต้านหุ่นยนต์", |
| 886 |
button_start: "คลิกเพื่อเริ่มการตรวจสอบ", |
| 887 |
text_fetching: "การดึงความท้าทาย", |
| 888 |
text_solving: "ยืนยันว่าคุณเป็นมนุษย์...", |
| 889 |
text_completed: "ฉันเป็นมนุษย์", |
| 890 |
text_completed_sr: "การตรวจสอบสแปมอัตโนมัติเสร็จสมบูรณ์", |
| 891 |
text_expired: "การตรวจสอบ ต่อต้านหุ่นยนต์ หมดอายุ", |
| 892 |
button_restart: "รีสตาร์ท", |
| 893 |
text_error: "การยืนยันล้มเหลว", |
| 894 |
button_retry: "ลองใหม่", |
| 895 |
text_fetch_error: "ไม่สามารถเชื่อมต่อได้" |
| 896 |
}; |
| 897 |
// South Korean |
| 898 |
var LANG_KR = { |
| 899 |
text_init: "초기화 중", |
| 900 |
text_ready: "Anti-Robot 검증", |
| 901 |
button_start: "검증을 위해 클릭해 주세요", |
| 902 |
text_fetching: "검증 준비 중", |
| 903 |
text_solving: "검증 중", |
| 904 |
text_completed: "검증이 완료되었습니다", |
| 905 |
text_completed_sr: "자동 스팸 확인 완료", |
| 906 |
text_expired: "Anti-Robot 검증 만료", |
| 907 |
button_restart: "다시 시작합니다", |
| 908 |
text_error: "검증 실패", |
| 909 |
button_retry: "다시 시도해 주세요", |
| 910 |
text_fetch_error: "연결하지 못했습니다" |
| 911 |
}; |
| 912 |
// Arabic |
| 913 |
var LANG_AR = { |
| 914 |
text_init: "...التهيئة", |
| 915 |
text_ready: "يتم التحقيق", |
| 916 |
button_start: "إضغط هنا للتحقيق", |
| 917 |
text_fetching: "تهيئة التحدي", |
| 918 |
text_solving: "نتحقق من أنك لست روبوتًا...", |
| 919 |
text_completed: "أنا لست روبوتًا", |
| 920 |
text_completed_sr: "تم الانتهاء من التحقق التلقائي من البريد العشوائي", |
| 921 |
text_expired: "انتهت صلاحية التحقق", |
| 922 |
button_restart: "إعادة تشغيل", |
| 923 |
text_error: "فشل التحقق", |
| 924 |
button_retry: "ابدأ مرة أخرى", |
| 925 |
text_fetch_error: "مشكلة في الاتصال مع" |
| 926 |
}; |
| 927 |
var localizations = { |
| 928 |
en: LANG_EN, |
| 929 |
de: LANG_DE, |
| 930 |
nl: LANG_NL, |
| 931 |
fr: LANG_FR, |
| 932 |
it: LANG_IT, |
| 933 |
pt: LANG_PT, |
| 934 |
es: LANG_ES, |
| 935 |
ca: LANG_CA, |
| 936 |
ja: LANG_JA, |
| 937 |
da: LANG_DA, |
| 938 |
ru: LANG_RU, |
| 939 |
sv: LANG_SV, |
| 940 |
tr: LANG_TR, |
| 941 |
el: LANG_EL, |
| 942 |
uk: LANG_UK, |
| 943 |
bg: LANG_BG, |
| 944 |
cs: LANG_CS, |
| 945 |
sk: LANG_SK, |
| 946 |
no: LANG_NO, |
| 947 |
fi: LANG_FI, |
| 948 |
lv: LANG_LV, |
| 949 |
lt: LANG_LT, |
| 950 |
pl: LANG_PL, |
| 951 |
et: LANG_ET, |
| 952 |
hr: LANG_HR, |
| 953 |
sr: LANG_SR, |
| 954 |
sl: LANG_SL, |
| 955 |
hu: LANG_HU, |
| 956 |
ro: LANG_RO, |
| 957 |
zh: LANG_ZH, |
| 958 |
zh_tw: LANG_ZH_TW, |
| 959 |
vi: LANG_VI, |
| 960 |
he: LANG_HE, |
| 961 |
th: LANG_TH, |
| 962 |
kr: LANG_KR, |
| 963 |
ar: LANG_AR, |
| 964 |
// alternative language codes |
| 965 |
nb: LANG_NO |
| 966 |
}; |
| 967 |
function createDiagnosticsBuffer(solverID, timeToSolved) { |
| 968 |
var arr = new Uint8Array(3); |
| 969 |
var view = new DataView(arr.buffer); |
| 970 |
view.setUint8(0, solverID); |
| 971 |
view.setUint16(1, timeToSolved); |
| 972 |
return arr; |
| 973 |
} |
| 974 |
var workerString = "!function(){function A(r){return A=\"function\"==typeof Symbol&&\"symbol\"==typeof Symbol.iterator?function(A){return typeof A}:function(A){return A&&\"function\"==typeof Symbol&&A.constructor===Symbol&&A!==Symbol.prototype?\"symbol\":typeof A},A(r)}function r(A,r){(null==r||r>A.length)&&(r=A.length);for(var t=0,n=Array(r);t<r;t++)n[t]=A[t];return n}function t(A,r){for(var t=0;t<r.length;t++){var n=r[t];n.enumerable=n.enumerable||!1,n.configurable=!0,\"value\"in n&&(n.writable=!0),Object.defineProperty(A,e(n.key),n)}}function n(A,r,n){return r&&t(A.prototype,r),n&&t(A,n),Object.defineProperty(A,\"prototype\",{writable:!1}),A}function e(r){var t=function(r){if(\"object\"!=A(r)||!r)return r;var t=r[Symbol.toPrimitive];if(void 0!==t){var n=t.call(r,\"string\");if(\"object\"!=A(n))return n;throw new TypeError(\"@@toPrimitive must return a primitive value.\")}return String(r)}(r);return\"symbol\"==A(t)?t:t+\"\"}!function(){\"use strict\";var A,r=[];function t(){for(;r.length;)r[0](),r.shift()}function n(A){this.a=e,this.b=void 0,this.f=[];var r=this;try{A((function(A){i(r,A)}),(function(A){g(r,A)}))}catch(t){g(r,t)}}A=function(){setTimeout(t)};var e=2;function o(A){return new n((function(r){r(A)}))}function i(A,r){if(A.a==e){if(r==A)throw new TypeError;var t=!1;try{var n=r&&r.then;if(null!=r&&\"object\"==typeof r&&\"function\"==typeof n)return void n.call(r,(function(r){t||i(A,r),t=!0}),(function(r){t||g(A,r),t=!0}))}catch(o){return void(t||g(A,o))}A.a=0,A.b=r,I(A)}}function g(A,r){if(A.a==e){if(r==A)throw new TypeError;A.a=1,A.b=r,I(A)}}function I(t){!function(t){r.push(t),1==r.length&&A()}((function(){if(t.a!=e)for(;t.f.length;){var A=(o=t.f.shift())[0],r=o[1],n=o[2],o=o[3];try{0==t.a?n(\"function\"==typeof A?A.call(void 0,t.b):t.b):1==t.a&&(\"function\"==typeof r?n(r.call(void 0,t.b)):o(t.b))}catch(i){o(i)}}}))}n.prototype.g=function(A){return this.c(void 0,A)},n.prototype.c=function(A,r){var t=this;return new n((function(n,e){t.f.push([A,r,n,e]),I(t)}))},self.Promise||(self.Promise=n,self.Promise.resolve=o,self.Promise.reject=function(A){return new n((function(r,t){t(A)}))},self.Promise.race=function(A){return new n((function(r,t){for(var n=0;n<A.length;n+=1)o(A[n]).c(r,t)}))},self.Promise.all=function(A){return new n((function(r,t){function n(t){return function(n){i[t]=n,(e+=1)==A.length&&r(i)}}var e=0,i=[];0==A.length&&r(i);for(var g=0;g<A.length;g+=1)o(A[g]).c(n(g),t)}))},self.Promise.prototype.then=n.prototype.c,self.Promise.prototype.catch=n.prototype.g)}(),function(){\"use strict\";for(var A=\"=\".charCodeAt(0),t=new Uint8Array(256),e=0;e<64;e++)t[\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\".charCodeAt(e)]=e;var o=n((function A(r){!function(A,r){if(!(A instanceof r))throw new TypeError(\"Cannot call a class as a function\")}(this,A),this.b=new Uint8Array(128),this.h=new Uint32Array(16),this.t=0,this.c=0,this.v=new Uint32Array(32),this.m=new Uint32Array(32),this.outlen=r}));function i(A,r){return A[r]^A[r+1]<<8^A[r+2]<<16^A[r+3]<<24}function g(A,r,t,n,e,o,i,g){var I,C,Q,c=r[i],a=r[i+1],f=r[g],u=r[g+1],B=A[t],s=A[t+1],E=A[n],l=A[n+1],h=A[e],w=A[e+1],y=A[o],v=A[o+1];Q=v^(s=(s=s+l+((B&E|(B|E)&~(I=B+E))>>>31))+a+(((B=I)&c|(B|c)&~(I=B+c))>>>31)),E=(Q=(l=(Q=l^(w=w+(v=C=y^(B=I))+((h&(y=Q)|(h|y)&~(I=h+y))>>>31)))>>>24^(C=E^(h=I))<<8)^(w=w+(v=(Q=v^(s=(s=s+l+((B&(E=C>>>24^Q<<8)|(B|E)&~(I=B+E))>>>31))+u+(((B=I)&f|(B|f)&~(I=B+f))>>>31)))>>>16^(C=y^(B=I))<<16)+((h&(y=C>>>16^Q<<16)|(h|y)&~(I=h+y))>>>31)))>>>31^(C=E^(h=I))<<1,l=C>>>31^Q<<1,A[t]=B,A[t+1]=s,A[n]=E,A[n+1]=l,A[e]=h,A[e+1]=w,A[o]=y,A[o+1]=v}var I,C,Q=[4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225],c=[0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,28,20,8,16,18,30,26,12,2,24,0,4,22,14,10,6,22,16,24,0,10,4,30,26,20,28,6,12,14,2,18,8,14,18,6,2,26,24,22,28,4,12,10,20,8,0,30,16,18,0,10,14,4,8,20,30,28,2,22,24,12,16,6,26,4,24,12,20,0,22,16,6,8,26,14,10,30,28,2,18,24,10,2,30,28,26,8,20,0,14,12,6,18,4,16,22,26,22,14,28,24,2,6,18,10,0,30,8,16,12,4,20,12,30,28,18,22,6,0,16,24,4,26,14,2,8,20,10,20,4,16,8,14,12,2,10,30,22,18,28,6,24,26,0,0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,28,20,8,16,18,30,26,12,2,24,0,4,22,14,10,6];function a(A,r){for(var t=A.v,n=A.m,e=0;e<16;e++)t[e]=A.h[e],t[e+16]=Q[e];t[24]=t[24]^A.t,t[25]=t[25]^A.t/4294967296,r&&(t[28]=~t[28],t[29]=~t[29]);for(var o=0;o<32;o++)n[o]=i(A.b,4*o);for(var I=0;I<12;I++)g(t,n,0,8,16,24,c[16*I+0],c[16*I+1]),g(t,n,2,10,18,26,c[16*I+2],c[16*I+3]),g(t,n,4,12,20,28,c[16*I+4],c[16*I+5]),g(t,n,6,14,22,30,c[16*I+6],c[16*I+7]),g(t,n,0,10,20,30,c[16*I+8],c[16*I+9]),g(t,n,2,12,22,24,c[16*I+10],c[16*I+11]),g(t,n,4,14,16,26,c[16*I+12],c[16*I+13]),g(t,n,6,8,18,28,c[16*I+14],c[16*I+15]);for(var C=0;C<16;C++)A.h[C]=A.h[C]^t[C]^t[C+16]}function f(A,r){for(var t=0;t<16;t++)A.h[t]=Q[t];A.b.set(r),A.h[0]^=16842752^A.outlen}function u(){return new Promise((function(A){return A((function(A,r){var t=function(A,r,t){if(128!=A.length)throw Error(\"Invalid input\");var n=A.buffer,e=new DataView(n),i=new o(32);i.t=128;for(var g=e.getUint32(124,!0),I=g+t,C=g;C<I;C++)if(e.setUint32(124,C,!0),f(i,A),a(i,!0),i.h[0]<r)return 0==ASC_TARGET?new Uint8Array(i.h.buffer):Uint8Array.wrap(i.h.buffer);return new Uint8Array(0)}(A,r,arguments.length>2&&void 0!==arguments[2]?arguments[2]:4294967295);return[A,t]}))}))}Uint8Array.prototype.slice||Object.defineProperty(Uint8Array.prototype,\"slice\",{value:function(A,r){return new Uint8Array(Array.prototype.slice.call(this,A,r))}}),self.ASC_TARGET=0;var B=new Promise((function(A){return C=A}));self.onerror=function(A){self.postMessage({type:\"error\",message:JSON.stringify(A)})},self.onmessage=function(n){return new Promise((function(e,o){var i;i=n.data;var g=function(){try{return e()}catch(A){return o(A)}},Q=function(A){try{return setTimeout((function(){throw A})),g()}catch(r){return o(r)}};try{var c=function(){return g()};if(\"solver\"!==i.type){var a,f,s,E,l=function(){return c.call(this)};return\"start\"===i.type?Promise.resolve(B).then(function(A){try{a=A,self.postMessage({type:\"started\"}),f=0;for(var t=0;t<256;t++){i.puzzleSolverInput[123]=t;var n=function(A){if(Array.isArray(A))return A}(o=a(i.puzzleSolverInput,i.threshold))||function(A){var r=null==A?null:\"undefined\"!=typeof Symbol&&A[Symbol.iterator]||A[\"@@iterator\"];if(null!=r){var t,n,e,o,i=[],g=!0,I=!1;try{for(e=(r=r.call(A)).next;!(g=(t=e.call(r)).done)&&(i.push(t.value),2!==i.length);g=!0);}catch(A){I=!0,n=A}finally{try{if(!g&&null!=r.return&&(o=r.return(),Object(o)!==o))return}finally{if(I)throw n}}return i}}(o)||function(A){if(A){if(\"string\"==typeof A)return r(A,2);var t={}.toString.call(A).slice(8,-1);return\"Object\"===t&&A.constructor&&(t=A.constructor.name),\"Map\"===t||\"Set\"===t?Array.from(A):\"Arguments\"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?r(A,2):void 0}}(o)||function(){throw new TypeError(\"Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\")}(),e=n[0];if(0!==n[1].length){s=e;break}console.warn(\"FC: Internal error or no solution found\"),f+=Math.pow(2,32)-1}return E=new DataView(s.slice(-4).buffer),f+=E.getUint32(0,!0),self.postMessage({type:\"done\",solution:s.slice(-8),h:f,puzzleIndex:i.puzzleIndex,puzzleNumber:i.puzzleNumber}),l.call(this)}catch(g){return Q(g)}var o}.bind(this),Q):l.call(this)}var h=function(){return self.postMessage({type:\"ready\",solver:I}),c.call(this)};if(i.forceJS)return I=1,Promise.resolve(u()).then(function(A){try{return C(A),h.call(this)}catch(r){return Q(r)}}.bind(this),Q);var w=function(){try{return h.call(this)}catch(A){return Q(A)}}.bind(this),y=function(A){try{return console.log(\"FriendlyCaptcha failed to initialize WebAssembly, falling back to Javascript solver: \"+A.toString()),I=1,Promise.resolve(u()).then((function(A){try{return C(A),w()}catch(r){return Q(r)}}),Q)}catch(r){return Q(r)}};try{var v;return I=2,v=WebAssembly.compile(function(r){var n=3285;r.charCodeAt(4379)===A&&n--,r.charCodeAt(4378)===A&&n--;for(var e=new Uint8Array(n),o=0,i=0;o<4380;o+=4){var g=t[r.charCodeAt(o+0)],I=t[r.charCodeAt(o+1)],C=t[r.charCodeAt(o+2)],Q=t[r.charCodeAt(o+3)];e[i++]=g<<2|I>>4,e[i++]=(15&I)<<4|C>>2,e[i++]=(3&C)<<6|63&Q}return e}(\"AGFzbQEAAAABKghgAABgAn9/AGADf39/AX9gAX8AYAR/f39/AGAAAX9gAX8Bf2ACf38BfwINAQNlbnYFYWJvcnQABAMMCwcGAwAAAQIFAQIABQMBAAEGFgR/AUEAC38BQQALfwBBAwt/AEHgDAsHbgkGbWVtb3J5AgAHX19hbGxvYwABCF9fcmV0YWluAAIJX19yZWxlYXNlAAMJX19jb2xsZWN0AAQHX19yZXNldAAFC19fcnR0aV9iYXNlAwMNVWludDhBcnJheV9JRAMCDHNvbHZlQmxha2UyYgAKCAELCvQSC5IBAQV/IABB8P///wNLBEAACyMBQRBqIgQgAEEPakFwcSICQRAgAkEQSxsiBmoiAj8AIgVBEHQiA0sEQCAFIAIgA2tB//8DakGAgHxxQRB2IgMgBSADShtAAEEASARAIANAAEEASARAAAsLCyACJAEgBEEQayICIAY2AgAgAkEBNgIEIAIgATYCCCACIAA2AgwgBAsEACAACwMAAQsDAAELBgAjACQBC7sCAQF/AkAgAUUNACAAQQA6AAAgACABakEEayICQQA6AAMgAUECTQ0AIABBADoAASAAQQA6AAIgAkEAOgACIAJBADoAASABQQZNDQAgAEEAOgADIAJBADoAACABQQhNDQAgAEEAIABrQQNxIgJqIgBBADYCACAAIAEgAmtBfHEiAmpBHGsiAUEANgIYIAJBCE0NACAAQQA2AgQgAEEANgIIIAFBADYCECABQQA2AhQgAkEYTQ0AIABBADYCDCAAQQA2AhAgAEEANgIUIABBADYCGCABQQA2AgAgAUEANgIEIAFBADYCCCABQQA2AgwgACAAQQRxQRhqIgFqIQAgAiABayEBA0AgAUEgTwRAIABCADcDACAAQgA3AwggAEIANwMQIABCADcDGCABQSBrIQEgAEEgaiEADAELCwsLcgACfyAARQRAQQxBAhABIQALIAALQQA2AgAgAEEANgIEIABBADYCCCABQfD///8DIAJ2SwRAQcAKQfAKQRJBORAAAAsgASACdCIBQQAQASICIAEQBiAAKAIAGiAAIAI2AgAgACACNgIEIAAgATYCCCAAC88BAQJ/QaABQQAQASIAQQxBAxABQYABQQAQBzYCACAAQQxBBBABQQhBAxAHNgIEIABCADcDCCAAQQA2AhAgAEIANwMYIABCADcDICAAQgA3AyggAEIANwMwIABCADcDOCAAQgA3A0AgAEIANwNIIABCADcDUCAAQgA3A1ggAEIANwNgIABCADcDaCAAQgA3A3AgAEIANwN4IABCADcDgAEgAEIANwOIASAAQgA3A5ABQYABQQUQASIBQYABEAYgACABNgKYASAAQSA2ApwBIAAL2AkCA38SfiAAKAIEIQIgACgCmAEhAwNAIARBgAFIBEAgAyAEaiABIARqKQMANwMAIARBCGohBAwBCwsgAigCBCkDACEMIAIoAgQpAwghDSACKAIEKQMQIQ4gAigCBCkDGCEPIAIoAgQpAyAhBSACKAIEKQMoIQsgAigCBCkDMCEGIAIoAgQpAzghB0KIkvOd/8z5hOoAIQhCu86qptjQ67O7fyEJQqvw0/Sv7ry3PCEQQvHt9Pilp/2npX8hCiAAKQMIQtGFmu/6z5SH0QCFIRFCn9j52cKR2oKbfyESQpSF+aXAyom+YCETQvnC+JuRo7Pw2wAhFEEAIQQDQCAEQcABSARAIAUgCCARIAwgBSADIARBgAhqIgEtAABBA3RqKQMAfHwiBYVCIIoiDHwiCIVCGIoiESAIIAwgBSARIAMgAS0AAUEDdGopAwB8fCIMhUIQiiIIfCIVhUI/iiEFIAsgCSASIA0gCyADIAEtAAJBA3RqKQMAfHwiDYVCIIoiCXwiEYVCGIohCyAGIBAgEyAOIAYgAyABLQAEQQN0aikDAHx8IgaFQiCKIg58IhCFQhiKIhIgECAOIAYgEiADIAEtAAVBA3RqKQMAfHwiDoVCEIoiE3wiEIVCP4ohBiAHIAogFCAPIAcgAyABLQAGQQN0aikDAHx8IgeFQiCKIg98IgqFQhiKIhIgCiAPIAcgEiADIAEtAAdBA3RqKQMAfHwiD4VCEIoiCnwiEoVCP4ohByAQIAogDCARIAkgDSALIAMgAS0AA0EDdGopAwB8fCINhUIQiiIJfCIWIAuFQj+KIgwgAyABLQAIQQN0aikDAHx8IhCFQiCKIgp8IgsgECALIAyFQhiKIhEgAyABLQAJQQN0aikDAHx8IgwgCoVCEIoiFHwiECARhUI/iiELIAYgEiAIIA0gBiADIAEtAApBA3RqKQMAfHwiDYVCIIoiCHwiCoVCGIoiBiANIAYgAyABLQALQQN0aikDAHx8Ig0gCIVCEIoiESAKfCIKhUI/iiEGIAcgFSAJIA4gByADIAEtAAxBA3RqKQMAfHwiDoVCIIoiCHwiCYVCGIoiByAOIAcgAyABLQANQQN0aikDAHx8Ig4gCIVCEIoiEiAJfCIIhUI/iiEHIAUgFiATIA8gBSADIAEtAA5BA3RqKQMAfHwiD4VCIIoiCXwiFYVCGIoiBSAPIAUgAyABLQAPQQN0aikDAHx8Ig8gCYVCEIoiEyAVfCIJhUI/iiEFIARBEGohBAwBCwsgAigCBCACKAIEKQMAIAggDIWFNwMAIAIoAgQgAigCBCkDCCAJIA2FhTcDCCACKAIEIAIoAgQpAxAgDiAQhYU3AxAgAigCBCACKAIEKQMYIAogD4WFNwMYIAIoAgQgAigCBCkDICAFIBGFhTcDICACKAIEIAIoAgQpAyggCyAShYU3AyggAigCBCACKAIEKQMwIAYgE4WFNwMwIAIoAgQgAigCBCkDOCAHIBSFhTcDOCAAIAw3AxggACANNwMgIAAgDjcDKCAAIA83AzAgACAFNwM4IAAgCzcDQCAAIAY3A0ggACAHNwNQIAAgCDcDWCAAIAk3A2AgACAQNwNoIAAgCjcDcCAAIBE3A3ggACASNwOAASAAIBM3A4gBIAAgFDcDkAEL4QIBBH8gACgCCEGAAUcEQEHQCUGACkEeQQUQAAALIAAoAgAhBBAIIgMoAgQhBSADQoABNwMIIAQoAnwiACACaiEGA0AgACAGSQRAIAQgADYCfCADKAIEIgIoAgQgAygCnAGtQoiS95X/zPmE6gCFNwMAIAIoAgRCu86qptjQ67O7fzcDCCACKAIEQqvw0/Sv7ry3PDcDECACKAIEQvHt9Pilp/2npX83AxggAigCBELRhZrv+s+Uh9EANwMgIAIoAgRCn9j52cKR2oKbfzcDKCACKAIEQuv6htq/tfbBHzcDMCACKAIEQvnC+JuRo7Pw2wA3AzggAyAEEAkgBSgCBCkDAKcgAUkEQEEAIAUoAgAiAUEQaygCDCICSwRAQfALQbAMQc0NQQUQAAALQQxBAxABIgAgATYCACAAIAI2AgggACABNgIEIAAPCyAAQQFqIQAMAQsLQQxBAxABQQBBABAHCwwAQaANJABBoA0kAQsL+gQJAEGBCAu/AQECAwQFBgcICQoLDA0ODw4KBAgJDw0GAQwAAgsHBQMLCAwABQIPDQoOAwYHAQkEBwkDAQ0MCw4CBgUKBAAPCAkABQcCBAoPDgELDAYIAw0CDAYKAAsIAwQNBwUPDgEJDAUBDw4NBAoABwYDCQIICw0LBw4MAQMJBQAPBAgGAgoGDw4JCwMACAwCDQcBBAoFCgIIBAcGAQUPCwkOAwwNAAABAgMEBQYHCAkKCwwNDg8OCgQICQ8NBgEMAAILBwUDAEHACQspGgAAAAEAAAABAAAAGgAAAEkAbgB2AGEAbABpAGQAIABpAG4AcAB1AHQAQfAJCzEiAAAAAQAAAAEAAAAiAAAAcwByAGMALwBzAG8AbAB2AGUAcgBXAGEAcwBtAC4AdABzAEGwCgsrHAAAAAEAAAABAAAAHAAAAEkAbgB2AGEAbABpAGQAIABsAGUAbgBnAHQAaABB4AoLNSYAAAABAAAAAQAAACYAAAB+AGwAaQBiAC8AYQByAHIAYQB5AGIAdQBmAGYAZQByAC4AdABzAEGgCws1JgAAAAEAAAABAAAAJgAAAH4AbABpAGIALwBzAHQAYQB0AGkAYwBhAHIAcgBhAHkALgB0AHMAQeALCzMkAAAAAQAAAAEAAAAkAAAASQBuAGQAZQB4ACAAbwB1AHQAIABvAGYAIAByAGEAbgBnAGUAQaAMCzMkAAAAAQAAAAEAAAAkAAAAfgBsAGkAYgAvAHQAeQBwAGUAZABhAHIAcgBhAHkALgB0AHMAQeAMCy4GAAAAIAAAAAAAAAAgAAAAAAAAACAAAAAAAAAAYQAAAAIAAAAhAgAAAgAAACQC\")),Promise.resolve(v).then((function(A){try{return Promise.resolve(function(A){return new Promise((function(r,t){var n,e,o;return Promise.resolve(function(A){return new Promise((function(r,t){var n,e;return n={env:{abort:function(){throw Error(\"Wasm aborted\")}}},Promise.resolve(WebAssembly.instantiate(A,n)).then((function(A){try{return e=function(A){var r={},t=A.exports,n=t.memory,e=t.__alloc,o=t.__retain,i=t.__rtti_base||-1;return r.__allocArray=function(A,r){var t=function(A){return new Uint32Array(n.buffer)[(i+4>>>2)+2*A]}(A),g=31-Math.clz32(t>>>6&31),I=r.length,C=e(I<<g,0),Q=e(12,A),c=new Uint32Array(n.buffer);c[Q+0>>>2]=o(C),c[Q+4>>>2]=C,c[Q+8>>>2]=I<<g;var a=n.buffer,f=new Uint8Array(a);if(16384&t)for(var u=0;u<I;++u)f[(C>>>g)+u]=o(r[u]);else f.set(r,C>>>g);return Q},r.__getUint8Array=function(A){var r=new Uint32Array(n.buffer),t=r[A+4>>>2];return new Uint8Array(n.buffer,t,r[t-4>>>2]>>>0)},function(A){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},t=A.__argumentsLength?function(r){A.__argumentsLength.value=r}:A.__setArgumentsLength||A.__setargc||function(){return{}},n=function(){if(!Object.prototype.hasOwnProperty.call(A,e))return 1;var n=A[e],o=e.split(\".\")[0];\"function\"==typeof n&&n!==t?(r[o]=function(){return t(arguments.length),n.apply(void 0,arguments)}).original=n:r[o]=n};for(var e in A)n();return r}(t,r)}(A),r({exports:e})}catch(n){return t(n)}}),t)}))}(A)).then((function(A){try{return e=(n=A).exports.__retain(n.exports.__allocArray(n.exports.Uint8Array_ID,new Uint8Array(128))),o=n.exports.__getUint8Array(e),r((function(A,r){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:4294967295;o.set(A);var i=n.exports.solveBlake2b(e,r,t);o=n.exports.__getUint8Array(e);var g=n.exports.__getUint8Array(i);return n.exports.__release(i),[o,g]}))}catch(i){return t(i)}}),t)}))}(A)).then((function(A){try{return C(A),w()}catch(r){return y(r)}}),y)}catch(r){return y(r)}}),y)}catch(p){y(p)}}catch(p){Q(p)}}))}}()}(\"undefined\"==typeof frcWorker?frcWorker={}:frcWorker);"; |
| 975 |
|
| 976 |
// Defensive init to make it easier to integrate with Gatsby and friends. |
| 977 |
var URL; |
| 978 |
if (typeof window !== "undefined") { |
| 979 |
URL = window.URL || window.webkitURL; |
| 980 |
} |
| 981 |
var WorkerGroup = /*#__PURE__*/function () { |
| 982 |
function WorkerGroup() { |
| 983 |
_classCallCheck(this, WorkerGroup); |
| 984 |
this.workers = []; |
| 985 |
this.puzzleNumber = 0; |
| 986 |
this.numPuzzles = 0; |
| 987 |
this.threshold = 0; |
| 988 |
this.startTime = 0; |
| 989 |
this.progress = 0; |
| 990 |
this.totalHashes = 0; |
| 991 |
this.puzzleSolverInputs = []; |
| 992 |
// The index of the next puzzle |
| 993 |
this.puzzleIndex = 0; |
| 994 |
this.solutionBuffer = new Uint8Array(0); |
| 995 |
// initialize some value, so ts is happy |
| 996 |
this.solverType = 1; |
| 997 |
this.readyPromise = new Promise(function () {}); |
| 998 |
this.readyCount = 0; |
| 999 |
this.startCount = 0; |
| 1000 |
this.progressCallback = function () { |
| 1001 |
return 0; |
| 1002 |
}; |
| 1003 |
this.readyCallback = function () { |
| 1004 |
return 0; |
| 1005 |
}; |
| 1006 |
this.startedCallback = function () { |
| 1007 |
return 0; |
| 1008 |
}; |
| 1009 |
this.doneCallback = function () { |
| 1010 |
return 0; |
| 1011 |
}; |
| 1012 |
this.errorCallback = function () { |
| 1013 |
return 0; |
| 1014 |
}; |
| 1015 |
} |
| 1016 |
return _createClass(WorkerGroup, [{ |
| 1017 |
key: "init", |
| 1018 |
value: function init() { |
| 1019 |
var _this = this; |
| 1020 |
this.terminateWorkers(); |
| 1021 |
this.progress = 0; |
| 1022 |
this.totalHashes = 0; |
| 1023 |
var setReady; |
| 1024 |
this.readyPromise = new Promise(function (resolve) { |
| 1025 |
return setReady = resolve; |
| 1026 |
}); |
| 1027 |
this.readyCount = 0; |
| 1028 |
this.startCount = 0; |
| 1029 |
// Setup four workers for now - later we could calculate this depending on the device |
| 1030 |
this.workers = new Array(4); |
| 1031 |
var workerBlob = new Blob([workerString], { |
| 1032 |
type: "text/javascript" |
| 1033 |
}); |
| 1034 |
var _loop = function _loop(_i4) { |
| 1035 |
_this.workers[_i4] = new Worker(URL.createObjectURL(workerBlob)); |
| 1036 |
_this.workers[_i4].onerror = function (e) { |
| 1037 |
return _this.errorCallback(e); |
| 1038 |
}; |
| 1039 |
_this.workers[_i4].onmessage = function (e) { |
| 1040 |
var data = e.data; |
| 1041 |
if (!data) return; |
| 1042 |
if (data.type === "ready") { |
| 1043 |
_this.readyCount++; |
| 1044 |
_this.solverType = data.solver; |
| 1045 |
// We are ready, when all workers are ready |
| 1046 |
if (_this.readyCount == _this.workers.length) { |
| 1047 |
setReady(); |
| 1048 |
_this.readyCallback(); |
| 1049 |
} |
| 1050 |
} else if (data.type === "started") { |
| 1051 |
_this.startCount++; |
| 1052 |
// We started, when the first worker starts working |
| 1053 |
if (_this.startCount == 1) { |
| 1054 |
_this.startTime = Date.now(); |
| 1055 |
_this.startedCallback(); |
| 1056 |
} |
| 1057 |
} else if (data.type === "done") { |
| 1058 |
if (data.puzzleNumber !== _this.puzzleNumber) return; // solution belongs to a previous puzzle |
| 1059 |
if (_this.puzzleIndex < _this.puzzleSolverInputs.length) { |
| 1060 |
_this.workers[_i4].postMessage({ |
| 1061 |
type: "start", |
| 1062 |
puzzleSolverInput: _this.puzzleSolverInputs[_this.puzzleIndex], |
| 1063 |
threshold: _this.threshold, |
| 1064 |
puzzleIndex: _this.puzzleIndex, |
| 1065 |
puzzleNumber: _this.puzzleNumber |
| 1066 |
}); |
| 1067 |
_this.puzzleIndex++; |
| 1068 |
} |
| 1069 |
_this.progress++; |
| 1070 |
_this.totalHashes += data.h; |
| 1071 |
_this.progressCallback({ |
| 1072 |
n: _this.numPuzzles, |
| 1073 |
h: _this.totalHashes, |
| 1074 |
t: (Date.now() - _this.startTime) / 1000, |
| 1075 |
i: _this.progress |
| 1076 |
}); |
| 1077 |
_this.solutionBuffer.set(data.solution, data.puzzleIndex * 8); |
| 1078 |
// We are done, when all puzzles have been solved |
| 1079 |
if (_this.progress == _this.numPuzzles) { |
| 1080 |
var totalTime = (Date.now() - _this.startTime) / 1000; |
| 1081 |
_this.doneCallback({ |
| 1082 |
solution: _this.solutionBuffer, |
| 1083 |
h: _this.totalHashes, |
| 1084 |
t: totalTime, |
| 1085 |
diagnostics: createDiagnosticsBuffer(_this.solverType, totalTime), |
| 1086 |
solver: _this.solverType |
| 1087 |
}); |
| 1088 |
} |
| 1089 |
} else if (data.type === "error") { |
| 1090 |
_this.errorCallback(data); |
| 1091 |
} |
| 1092 |
}; |
| 1093 |
}; |
| 1094 |
for (var _i4 = 0; _i4 < this.workers.length; _i4++) { |
| 1095 |
_loop(_i4); |
| 1096 |
} |
| 1097 |
} |
| 1098 |
}, { |
| 1099 |
key: "setupSolver", |
| 1100 |
value: function setupSolver() { |
| 1101 |
var forceJS = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; |
| 1102 |
var msg = { |
| 1103 |
type: "solver", |
| 1104 |
forceJS: forceJS |
| 1105 |
}; |
| 1106 |
for (var _i5 = 0; _i5 < this.workers.length; _i5++) { |
| 1107 |
this.workers[_i5].postMessage(msg); |
| 1108 |
} |
| 1109 |
} |
| 1110 |
}, { |
| 1111 |
key: "start", |
| 1112 |
value: function start(puzzle) { |
| 1113 |
return new Promise(function ($return, $error) { |
| 1114 |
return Promise.resolve(this.readyPromise).then(function ($await_11) { |
| 1115 |
try { |
| 1116 |
this.puzzleSolverInputs = getPuzzleSolverInputs(puzzle.buffer, puzzle.n); |
| 1117 |
this.solutionBuffer = new Uint8Array(8 * puzzle.n); |
| 1118 |
this.numPuzzles = puzzle.n; |
| 1119 |
this.threshold = puzzle.threshold; |
| 1120 |
this.puzzleIndex = 0; |
| 1121 |
this.puzzleNumber++; |
| 1122 |
for (var _i6 = 0; _i6 < this.workers.length; _i6++) { |
| 1123 |
if (this.puzzleIndex === this.puzzleSolverInputs.length) break; |
| 1124 |
this.workers[_i6].postMessage({ |
| 1125 |
type: "start", |
| 1126 |
puzzleSolverInput: this.puzzleSolverInputs[_i6], |
| 1127 |
threshold: this.threshold, |
| 1128 |
puzzleIndex: this.puzzleIndex, |
| 1129 |
puzzleNumber: this.puzzleNumber |
| 1130 |
}); |
| 1131 |
this.puzzleIndex++; |
| 1132 |
} |
| 1133 |
return $return(); |
| 1134 |
} catch ($boundEx) { |
| 1135 |
return $error($boundEx); |
| 1136 |
} |
| 1137 |
}.bind(this), $error); |
| 1138 |
}.bind(this)); |
| 1139 |
} |
| 1140 |
}, { |
| 1141 |
key: "terminateWorkers", |
| 1142 |
value: function terminateWorkers() { |
| 1143 |
if (this.workers.length == 0) return; |
| 1144 |
for (var _i7 = 0; _i7 < this.workers.length; _i7++) { |
| 1145 |
this.workers[_i7].terminate(); |
| 1146 |
} |
| 1147 |
this.workers = []; |
| 1148 |
} |
| 1149 |
}]); |
| 1150 |
}(); |
| 1151 |
var PUZZLE_ENDPOINT_URL = "https://api.friendlycaptcha.com/api/v1/puzzle"; |
| 1152 |
var WidgetInstance = /*#__PURE__*/function () { |
| 1153 |
function WidgetInstance(element) { |
| 1154 |
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; |
| 1155 |
_classCallCheck(this, WidgetInstance); |
| 1156 |
this.workerGroup = new WorkerGroup(); |
| 1157 |
/** |
| 1158 |
* The captcha has been succesfully solved. |
| 1159 |
*/ |
| 1160 |
this.valid = false; |
| 1161 |
/** |
| 1162 |
* Some errors may cause a need for the (worker) to be reinitialized. If this is |
| 1163 |
* true `init` will be called again when start is called. |
| 1164 |
*/ |
| 1165 |
this.needsReInit = false; |
| 1166 |
/** |
| 1167 |
* Start() has been called at least once ever. |
| 1168 |
*/ |
| 1169 |
this.hasBeenStarted = false; |
| 1170 |
this.hasBeenDestroyed = false; |
| 1171 |
this.opts = Object.assign({ |
| 1172 |
forceJSFallback: false, |
| 1173 |
skipStyleInjection: false, |
| 1174 |
startMode: "focus", |
| 1175 |
puzzleEndpoint: element.dataset["puzzleEndpoint"] || PUZZLE_ENDPOINT_URL, |
| 1176 |
startedCallback: function startedCallback() { |
| 1177 |
return 0; |
| 1178 |
}, |
| 1179 |
readyCallback: function readyCallback() { |
| 1180 |
return 0; |
| 1181 |
}, |
| 1182 |
doneCallback: function doneCallback() { |
| 1183 |
return 0; |
| 1184 |
}, |
| 1185 |
errorCallback: function errorCallback() { |
| 1186 |
return 0; |
| 1187 |
}, |
| 1188 |
sitekey: element.dataset["sitekey"] || "", |
| 1189 |
language: element.dataset["lang"] || "en", |
| 1190 |
solutionFieldName: element.dataset["solutionFieldName"] || "frc-captcha-solution", |
| 1191 |
styleNonce: null |
| 1192 |
}, options); |
| 1193 |
this.e = element; |
| 1194 |
this.e.friendlyChallengeWidget = this; |
| 1195 |
this.loadLanguage(); |
| 1196 |
// @ts-ignore Ignore is required as TS thinks that `this.lang` is not assigned yet, but it happens in `this.loadLanguage()` above. |
| 1197 |
element.innerText = this.lang.text_init; |
| 1198 |
if (!this.opts.skipStyleInjection) { |
| 1199 |
injectStyle(this.opts.styleNonce); |
| 1200 |
} |
| 1201 |
this.init(this.opts.startMode === "auto" || this.e.dataset["start"] === "auto"); |
| 1202 |
} |
| 1203 |
return _createClass(WidgetInstance, [{ |
| 1204 |
key: "init", |
| 1205 |
value: function init(forceStart) { |
| 1206 |
var _this2 = this; |
| 1207 |
if (this.hasBeenDestroyed) { |
| 1208 |
console.error("FriendlyCaptcha widget has been destroyed using destroy(), it can not be used anymore."); |
| 1209 |
return; |
| 1210 |
} |
| 1211 |
this.initWorkerGroup(); |
| 1212 |
if (forceStart) { |
| 1213 |
this.start(); |
| 1214 |
} else if (this.e.dataset["start"] !== "none" && (this.opts.startMode === "focus" || this.e.dataset["start"] === "focus")) { |
| 1215 |
var form = findParentFormElement(this.e); |
| 1216 |
if (form) { |
| 1217 |
executeOnceOnFocusInEvent(form, function () { |
| 1218 |
return _this2.start(); |
| 1219 |
}); |
| 1220 |
} else { |
| 1221 |
console.log("FriendlyCaptcha div seems not to be contained in a form, autostart will not work"); |
| 1222 |
} |
| 1223 |
} |
| 1224 |
} |
| 1225 |
/** |
| 1226 |
* Loads the configured language, or a language passed to this function. |
| 1227 |
* Note that only the next update will be in the new language, consider calling `reset()` after switching languages. |
| 1228 |
*/ |
| 1229 |
}, { |
| 1230 |
key: "loadLanguage", |
| 1231 |
value: function loadLanguage(lang) { |
| 1232 |
if (lang !== undefined) { |
| 1233 |
this.opts.language = lang; |
| 1234 |
} else if (this.e.dataset["lang"]) { |
| 1235 |
this.opts.language = this.e.dataset["lang"]; |
| 1236 |
} |
| 1237 |
if (typeof this.opts.language === "string") { |
| 1238 |
var langCode = this.opts.language.toLowerCase(); |
| 1239 |
var l = localizations[langCode]; |
| 1240 |
if (l === undefined && langCode[2] === "-") { |
| 1241 |
// Language has a locale '-' separator, remove it and try again |
| 1242 |
langCode = langCode.substring(0, 2); |
| 1243 |
l = localizations[langCode]; |
| 1244 |
} |
| 1245 |
if (l === undefined) { |
| 1246 |
console.error('FriendlyCaptcha: language "' + this.opts.language + '" not found.'); |
| 1247 |
// Fall back to English |
| 1248 |
l = localizations.en; |
| 1249 |
} |
| 1250 |
this.lang = l; |
| 1251 |
} else { |
| 1252 |
// We assign to a copy of the English language localization, so that any missing values will be English |
| 1253 |
this.lang = Object.assign(Object.assign({}, localizations.en), this.opts.language); |
| 1254 |
} |
| 1255 |
} |
| 1256 |
/** |
| 1257 |
* Add a listener to the button that calls `this.start` on click. |
| 1258 |
*/ |
| 1259 |
}, { |
| 1260 |
key: "makeButtonStart", |
| 1261 |
value: function makeButtonStart() { |
| 1262 |
var _this3 = this; |
| 1263 |
var b = this.e.querySelector("button"); |
| 1264 |
if (b) { |
| 1265 |
b.addEventListener("click", function (e) { |
| 1266 |
return _this3.start(); |
| 1267 |
}, { |
| 1268 |
once: true, |
| 1269 |
passive: true |
| 1270 |
}); |
| 1271 |
b.addEventListener("touchstart", function (e) { |
| 1272 |
return _this3.start(); |
| 1273 |
}, { |
| 1274 |
once: true, |
| 1275 |
passive: true |
| 1276 |
}); |
| 1277 |
} |
| 1278 |
} |
| 1279 |
}, { |
| 1280 |
key: "onWorkerError", |
| 1281 |
value: function onWorkerError(e) { |
| 1282 |
this.hasBeenStarted = false; |
| 1283 |
this.needsReInit = true; |
| 1284 |
if (this.expiryTimeout) clearTimeout(this.expiryTimeout); |
| 1285 |
console.error("[FRC]", e); |
| 1286 |
this.e.innerHTML = getErrorHTML(this.opts.solutionFieldName, this.lang, "Background worker error " + e.message); |
| 1287 |
this.makeButtonStart(); |
| 1288 |
// Just out of precaution |
| 1289 |
this.opts.forceJSFallback = true; |
| 1290 |
} |
| 1291 |
}, { |
| 1292 |
key: "initWorkerGroup", |
| 1293 |
value: function initWorkerGroup() { |
| 1294 |
var _this4 = this; |
| 1295 |
this.workerGroup.progressCallback = function (progress) { |
| 1296 |
updateProgressBar(_this4.e, progress); |
| 1297 |
}; |
| 1298 |
this.workerGroup.readyCallback = function () { |
| 1299 |
_this4.e.innerHTML = getReadyHTML(_this4.opts.solutionFieldName, _this4.lang); |
| 1300 |
_this4.makeButtonStart(); |
| 1301 |
_this4.opts.readyCallback(); |
| 1302 |
}; |
| 1303 |
this.workerGroup.startedCallback = function () { |
| 1304 |
_this4.e.innerHTML = getRunningHTML(_this4.opts.solutionFieldName, _this4.lang); |
| 1305 |
_this4.opts.startedCallback(); |
| 1306 |
}; |
| 1307 |
this.workerGroup.doneCallback = function (data) { |
| 1308 |
var solutionPayload = _this4.handleDone(data); |
| 1309 |
_this4.opts.doneCallback(solutionPayload); |
| 1310 |
var callback = _this4.e.dataset["callback"]; |
| 1311 |
if (callback) { |
| 1312 |
window[callback](solutionPayload); |
| 1313 |
} |
| 1314 |
}; |
| 1315 |
this.workerGroup.errorCallback = function (e) { |
| 1316 |
_this4.onWorkerError(e); |
| 1317 |
}; |
| 1318 |
this.workerGroup.init(); |
| 1319 |
this.workerGroup.setupSolver(this.opts.forceJSFallback); |
| 1320 |
} |
| 1321 |
}, { |
| 1322 |
key: "expire", |
| 1323 |
value: function expire() { |
| 1324 |
this.hasBeenStarted = false; |
| 1325 |
// Node.isConnected will be undefined in older browsers |
| 1326 |
if (this.e.isConnected !== false) { |
| 1327 |
this.e.innerHTML = getExpiredHTML(this.opts.solutionFieldName, this.lang); |
| 1328 |
this.makeButtonStart(); |
| 1329 |
} |
| 1330 |
} |
| 1331 |
}, { |
| 1332 |
key: "start", |
| 1333 |
value: function start() { |
| 1334 |
return new Promise(function ($return, $error) { |
| 1335 |
var sitekey; |
| 1336 |
if (this.hasBeenDestroyed) { |
| 1337 |
console.error("Can not start FriendlyCaptcha widget which has been destroyed"); |
| 1338 |
return $return(); |
| 1339 |
} |
| 1340 |
if (this.hasBeenStarted) { |
| 1341 |
console.warn("Can not start FriendlyCaptcha widget which has already been started"); |
| 1342 |
return $return(); |
| 1343 |
} |
| 1344 |
sitekey = this.opts.sitekey || this.e.dataset["sitekey"]; |
| 1345 |
if (!sitekey) { |
| 1346 |
console.error("FriendlyCaptcha: sitekey not set on frc-captcha element"); |
| 1347 |
this.e.innerHTML = getErrorHTML(this.opts.solutionFieldName, this.lang, "Website problem: sitekey not set", false); |
| 1348 |
return $return(); |
| 1349 |
} |
| 1350 |
if (isHeadless()) { |
| 1351 |
this.e.innerHTML = getErrorHTML(this.opts.solutionFieldName, this.lang, "Browser check failed, try a different browser", false, true); |
| 1352 |
return $return(); |
| 1353 |
} |
| 1354 |
if (this.needsReInit) { |
| 1355 |
this.needsReInit = false; |
| 1356 |
this.init(true); |
| 1357 |
return $return(); |
| 1358 |
} |
| 1359 |
this.hasBeenStarted = true; |
| 1360 |
var $Try_3_Post = function () { |
| 1361 |
try { |
| 1362 |
return Promise.resolve(this.workerGroup.start(this.puzzle)).then(function ($await_12) { |
| 1363 |
try { |
| 1364 |
return $return(); |
| 1365 |
} catch ($boundEx) { |
| 1366 |
return $error($boundEx); |
| 1367 |
} |
| 1368 |
}, $error); |
| 1369 |
} catch ($boundEx) { |
| 1370 |
return $error($boundEx); |
| 1371 |
} |
| 1372 |
}.bind(this); |
| 1373 |
var $Try_3_Catch = function (e) { |
| 1374 |
try { |
| 1375 |
{ |
| 1376 |
console.error("[FRC]", e); |
| 1377 |
this.hasBeenStarted = false; |
| 1378 |
if (this.expiryTimeout) clearTimeout(this.expiryTimeout); |
| 1379 |
this.e.innerHTML = getErrorHTML(this.opts.solutionFieldName, this.lang, e.message); |
| 1380 |
this.makeButtonStart(); |
| 1381 |
var code; |
| 1382 |
code = "error_getting_puzzle"; |
| 1383 |
this.opts.errorCallback({ |
| 1384 |
code: code, |
| 1385 |
description: e.toString(), |
| 1386 |
error: e |
| 1387 |
}); |
| 1388 |
var callback; |
| 1389 |
callback = this.e.dataset["callback-error"]; |
| 1390 |
if (callback) { |
| 1391 |
window[callback](this); |
| 1392 |
} |
| 1393 |
return $return(); |
| 1394 |
} |
| 1395 |
} catch ($boundEx) { |
| 1396 |
return $error($boundEx); |
| 1397 |
} |
| 1398 |
}.bind(this); |
| 1399 |
try { |
| 1400 |
this.e.innerHTML = getFetchingHTML(this.opts.solutionFieldName, this.lang); |
| 1401 |
return Promise.resolve(getPuzzle(this.opts.puzzleEndpoint, sitekey, this.lang)).then(function ($await_13) { |
| 1402 |
var _this5 = this; |
| 1403 |
try { |
| 1404 |
this.puzzle = decodeBase64Puzzle($await_13); |
| 1405 |
if (this.expiryTimeout) clearTimeout(this.expiryTimeout); |
| 1406 |
this.expiryTimeout = setTimeout(function () { |
| 1407 |
return _this5.expire(); |
| 1408 |
}, this.puzzle.expiry - 30000); // 30s grace |
| 1409 |
return $Try_3_Post(); |
| 1410 |
} catch ($boundEx) { |
| 1411 |
return $Try_3_Catch($boundEx); |
| 1412 |
} |
| 1413 |
}.bind(this), $Try_3_Catch); |
| 1414 |
} catch (e) { |
| 1415 |
$Try_3_Catch(e); |
| 1416 |
} |
| 1417 |
}.bind(this)); |
| 1418 |
} |
| 1419 |
/** |
| 1420 |
* This is to be called when the puzzle has been succesfully completed. |
| 1421 |
* Here the hidden field gets updated with the solution. |
| 1422 |
* @param data message from the webworker |
| 1423 |
*/ |
| 1424 |
}, { |
| 1425 |
key: "handleDone", |
| 1426 |
value: function handleDone(data) { |
| 1427 |
this.valid = true; |
| 1428 |
var puzzleSolutionMessage = "".concat(this.puzzle.signature, ".").concat(this.puzzle.base64, ".").concat(encode(data.solution), ".").concat(encode(data.diagnostics)); |
| 1429 |
this.e.innerHTML = getDoneHTML(this.opts.solutionFieldName, this.lang, puzzleSolutionMessage, data); |
| 1430 |
// this.worker = null; // This literally crashes very old browsers.. |
| 1431 |
this.needsReInit = true; |
| 1432 |
return puzzleSolutionMessage; |
| 1433 |
} |
| 1434 |
/** |
| 1435 |
* Cleans up the widget entirely, removing any DOM elements and terminating any background workers. |
| 1436 |
* After it is destroyed it can no longer be used for any purpose. |
| 1437 |
*/ |
| 1438 |
}, { |
| 1439 |
key: "destroy", |
| 1440 |
value: function destroy() { |
| 1441 |
this.workerGroup.terminateWorkers(); |
| 1442 |
this.needsReInit = false; |
| 1443 |
this.hasBeenStarted = false; |
| 1444 |
if (this.expiryTimeout) clearTimeout(this.expiryTimeout); |
| 1445 |
if (this.e) { |
| 1446 |
this.e.remove(); |
| 1447 |
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore |
| 1448 |
// @ts-ignore |
| 1449 |
delete this.e; |
| 1450 |
} |
| 1451 |
this.hasBeenDestroyed = true; |
| 1452 |
} |
| 1453 |
/** |
| 1454 |
* Resets the widget to the initial state. |
| 1455 |
* This is useful in situations where the page does not refresh when you submit and the form may be re-submitted again |
| 1456 |
*/ |
| 1457 |
}, { |
| 1458 |
key: "reset", |
| 1459 |
value: function reset() { |
| 1460 |
if (this.hasBeenDestroyed) { |
| 1461 |
console.error("FriendlyCaptcha widget has been destroyed, it can not be used anymore"); |
| 1462 |
return; |
| 1463 |
} |
| 1464 |
this.workerGroup.terminateWorkers(); |
| 1465 |
this.needsReInit = false; |
| 1466 |
this.hasBeenStarted = false; |
| 1467 |
if (this.expiryTimeout) clearTimeout(this.expiryTimeout); |
| 1468 |
this.init(this.opts.startMode === "auto" || this.e.dataset["start"] === "auto"); |
| 1469 |
} |
| 1470 |
}]); |
| 1471 |
}(); |
| 1472 |
window.friendlyChallenge = { |
| 1473 |
WidgetInstance: WidgetInstance |
| 1474 |
}; |
| 1475 |
function setup() { |
| 1476 |
var autoWidget = window.friendlyChallenge.autoWidget; |
| 1477 |
var elements = findCaptchaElements(); |
| 1478 |
for (var index = 0; index < elements.length; index++) { |
| 1479 |
var hElement = elements[index]; |
| 1480 |
if (hElement && !hElement.dataset["attached"]) { |
| 1481 |
autoWidget = new WidgetInstance(hElement); |
| 1482 |
// We set the "data-attached" attribute so we don't attach to the same element twice. |
| 1483 |
hElement.dataset["attached"] = "1"; |
| 1484 |
} |
| 1485 |
} |
| 1486 |
window.friendlyChallenge.autoWidget = autoWidget; |
| 1487 |
} |
| 1488 |
if (document.readyState !== "loading") { |
| 1489 |
setup(); |
| 1490 |
} else { |
| 1491 |
document.addEventListener("DOMContentLoaded", setup); |
| 1492 |
} |
| 1493 |
})(); |