From 9d2797cc014557670d997676176904b25bbeebf2 Mon Sep 17 00:00:00 2001 From: Jacob K Date: Sun, 14 Aug 2022 19:12:03 -0500 Subject: [Google Forms] Add (untested) checkbox support. --- src/docs-google-com-fix-forms/google_forms.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/docs-google-com-fix-forms/google_forms.js b/src/docs-google-com-fix-forms/google_forms.js index 2abf3fa..22e783c 100644 --- a/src/docs-google-com-fix-forms/google_forms.js +++ b/src/docs-google-com-fix-forms/google_forms.js @@ -45,6 +45,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; -- cgit v1.2.3 From 618dbc2a6d5eaadf51a3b13d518ce6275526f9d1 Mon Sep 17 00:00:00 2001 From: Jacob K Date: Sun, 14 Aug 2022 19:19:05 -0500 Subject: [Google Forms] Add copyright line and a minor text fix. --- src/docs-google-com-fix-forms/google_forms.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/docs-google-com-fix-forms/google_forms.js b/src/docs-google-com-fix-forms/google_forms.js index 22e783c..e9b7dfd 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 * Copyright 2022 Wojtek Kosior + * 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. @@ -45,7 +46,7 @@ for (let div of form.querySelectorAll('div[data-params]')) { new_radio.value = input_div.getAttribute("data-value"); input_div.replaceWith(new_radio); } - /* handle checkboxes */ + /* Handle checkboxes. */ for (const input_div of div.querySelectorAll('[data-answer-value]')) { const new_checkbox = document.createElement('input'); new_checkbox.type = 'checkbox'; @@ -89,3 +90,4 @@ for (const next_but of document.querySelectorAll('[jsname=OCpkoe]')) // TODO: // * support "back" with instatiation of previous entries // * find and fix form parts that still don't work (if any) + -- cgit v1.2.3 From 283be80b6d893b5fb6fa47ffe8694792e050faf5 Mon Sep 17 00:00:00 2001 From: Jacob K Date: Sun, 14 Aug 2022 20:05:56 -0500 Subject: [Google Forms] Add (untested) support for email address fields. --- src/docs-google-com-fix-forms/google_forms.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/docs-google-com-fix-forms/google_forms.js b/src/docs-google-com-fix-forms/google_forms.js index e9b7dfd..dcb2d54 100644 --- a/src/docs-google-com-fix-forms/google_forms.js +++ b/src/docs-google-com-fix-forms/google_forms.js @@ -27,9 +27,19 @@ 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. Those same classes appear on 3 email + fields in different forms that I found. */ + if (div.dataset.params) { + var 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) { -- cgit v1.2.3 From 07374f81693d83cdd56b8f64537d054c0b35d555 Mon Sep 17 00:00:00 2001 From: Jacob K Date: Sun, 14 Aug 2022 20:12:46 -0500 Subject: [Google Forms] Add more TODO items. --- src/docs-google-com-fix-forms/google_forms.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/docs-google-com-fix-forms/google_forms.js b/src/docs-google-com-fix-forms/google_forms.js index dcb2d54..4917ce8 100644 --- a/src/docs-google-com-fix-forms/google_forms.js +++ b/src/docs-google-com-fix-forms/google_forms.js @@ -97,7 +97,12 @@ 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) - +/* 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") +*/ -- cgit v1.2.3