aboutsummaryrefslogtreecommitdiff
path: root/src/docs-google-com-fix-forms/google_forms.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/docs-google-com-fix-forms/google_forms.js')
-rw-r--r--src/docs-google-com-fix-forms/google_forms.js43
1 files changed, 37 insertions, 6 deletions
diff --git a/src/docs-google-com-fix-forms/google_forms.js b/src/docs-google-com-fix-forms/google_forms.js
index 2abf3fa..4652426 100644
--- a/src/docs-google-com-fix-forms/google_forms.js
+++ b/src/docs-google-com-fix-forms/google_forms.js
@@ -5,6 +5,7 @@
*
* Copyright © 2021 jahoti <jahoti@tilde.team>
* Copyright 2022 Wojtek Kosior <koszko@koszko.org>
+ * Copytight 2022 Jacob K
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -26,9 +27,20 @@
var form = document.forms[0];
/* Fix form fields. */
-for (let div of form.querySelectorAll('div[data-params]')) {
- var data = JSON.parse('[' + div.dataset.params.substring(4));
- var name = 'entry.' + data[0][4][0][0];
+for (let div of form.querySelectorAll('div[data-params], div.geS5n.AgroKb.oQYVNd')) {
+ /*
+ * The selector, "div.geS5n.AgroKb.oQYVNd", is to catch email fields, which
+ * don't have a data-params attribute.
+ */
+ if (div.dataset.params) {
+ const data = JSON.parse('[' + div.dataset.params.substring(4));
+ var name = 'entry.' + data[0][4][0][0];
+ } else if (div.className == "geS5n AgroKb oQYVNd") {
+ var name = "emailAddress";
+ } else {
+ console.error(`Cannot enable input`, div);
+ continue;
+ }
var input = div.querySelector('input, textarea');
if (!input) {
@@ -45,6 +57,14 @@ for (let div of form.querySelectorAll('div[data-params]')) {
new_radio.value = input_div.getAttribute("data-value");
input_div.replaceWith(new_radio);
}
+ /* Handle checkboxes. */
+ for (const input_div of div.querySelectorAll('[data-answer-value]')) {
+ const new_checkbox = document.createElement('input');
+ new_checkbox.type = 'checkbox';
+ new_checkbox.name = name;
+ new_checkbox.value = input_div.getAttribute("data-answer-value");
+ input_div.replaceWith(new_checkbox);
+ }
} else {
input.removeAttribute('disabled');
input.name = name;
@@ -78,6 +98,17 @@ function goToNext()
for (const next_but of document.querySelectorAll('[jsname=OCpkoe]'))
next_but.addEventListener("click", goToNext);
-// TODO:
-// * support "back" with instatiation of previous entries
-// * find and fix form parts that still don't work (if any)
+/* Remove no JavaScript warning (if any). */
+for (const warning of
+ document.querySelectorAll(".HB1eCd-X3SwIb-i8xkGf, noscript"))
+ warning.remove();
+
+/* TODO:
+ * support "back" with instatiation of previous entries
+ * find and fix form parts that still don't work (if any)
+ * support dropdown inputs
+ * support "other" radio buttons and "other" checkbox buttons, in which the
+ user types text in addition to selecting the "other" box
+ * support reCAPTCHA integration
+ * support displaying public analytics ("viewanalytics" instead of "viewform")
+*/