aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/google_forms.js37
1 files changed, 24 insertions, 13 deletions
diff --git a/src/google_forms.js b/src/google_forms.js
index 54c1a04..2abf3fa 100644
--- a/src/google_forms.js
+++ b/src/google_forms.js
@@ -24,18 +24,21 @@
*/
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];
- var input = div.querySelector('input');
+ var input = div.querySelector('input, textarea');
if (!input) {
console.error(`cannot enable input ${name}`, div);
continue;
}
- if (input.name === name + '_sentinel') { // Radio
- for (const input_div of div.querySelectorAll('.appsMaterialWizToggleRadiogroupEl')) {
+ if (input.name === name + '_sentinel') {
+ /* Handle radio buttons. */
+ for (const input_div of div.querySelectorAll('[data-value]')) {
const new_radio = document.createElement('input');
new_radio.type = 'radio';
new_radio.name = name;
@@ -45,12 +48,23 @@ for (let div of form.querySelectorAll('div[data-params]')) {
} else {
input.removeAttribute('disabled');
input.name = name;
+
+ /* Enlarge textareas and make them stand out from mere input fields. */
+ if (input.tagName === "TEXTAREA") {
+ input.style.height = "8em";
+ input.style.overflowY = "scroll";
+ }
}
}
-for (div of document.querySelectorAll('.quantumWizTextinputPaperinputPlaceholder'))
- div.remove();
+/* Remove placeholders in text input fields and textareas. */
+document.querySelectorAll('[jsname=LwH6nd]').forEach(n => n.remove());
+/* Enable the form sumbission button (if any). */
+for (const submit_but of document.querySelectorAll('[jsname=M2UYVd]'))
+ submit_but.addEventListener("click", () => form.submit());
+
+/* Enable the "next page" button (if any). */
function goToNext()
{
var next = document.createElement('input');
@@ -61,12 +75,9 @@ function goToNext()
form.submit();
}
-const submit_selector = ".freebirdFormviewerViewNavigationSubmitButton";
-const next_selector = ".freebirdFormviewerViewNavigationNoSubmitButton";
-for (const but_div of document.querySelectorAll(submit_selector))
- but_div.addEventListener("click", () => form.submit());
-
-for (const but_div of document.querySelectorAll(next_selector))
- but_div.addEventListener("click", goToNext);
+for (const next_but of document.querySelectorAll('[jsname=OCpkoe]'))
+ next_but.addEventListener("click", goToNext);
-// TODO: back, instate previous entries, fix form parts that still don't work
+// TODO:
+// * support "back" with instatiation of previous entries
+// * find and fix form parts that still don't work (if any)