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