aboutsummaryrefslogtreecommitdiff
path: root/src/google-com-fix-sorry-captcha/google-sorry.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/google-com-fix-sorry-captcha/google-sorry.js')
-rw-r--r--src/google-com-fix-sorry-captcha/google-sorry.js47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/google-com-fix-sorry-captcha/google-sorry.js b/src/google-com-fix-sorry-captcha/google-sorry.js
new file mode 100644
index 0000000..adbf519
--- /dev/null
+++ b/src/google-com-fix-sorry-captcha/google-sorry.js
@@ -0,0 +1,47 @@
+/* SPDX-License-Identifier: CC0-1.0
+ *
+ * Code to run Hacktcha on Google's "sorry" page.
+ *
+ * Copyright (C) 2022 Wojtek Kosior
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the CC0 1.0 Universal License as published by
+ * the Creative Commons Corporation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * CC0 1.0 Universal License for more details.
+ */
+
+/* Use with https://www.google.com/sorry/index */
+
+"use strict";
+
+(async () => {
+ const form = document.getElementById("captcha-form");
+ const recaptcha_div = form.querySelector("#recaptcha");
+ const site_key = recaptcha_div.getAttribute("data-sitekey");
+
+ for (const warning of
+ document.querySelectorAll("noscript, form div[style^=font-size]"))
+ warning.style.display = "none";
+
+ for await (const token of HCHA.run(recaptcha_div, site_key)) {
+ if (token !== null) {
+ const token_field = document.createElement("textarea");
+
+ token_field.setAttribute("type", "hidden");
+ token_field.value = token;
+ token_field.name = "g-recaptcha-response";
+
+ recaptcha_div.after(token_field);
+
+ form.submit();
+
+ recaptcha_div.style.display = "none";
+
+ await new Promise(cb => {});
+ }
+ }
+})();