From c6505d419b6c6a6207c6418ede107d00e6792015 Mon Sep 17 00:00:00 2001 From: Wojtek Kosior Date: Tue, 8 Mar 2022 00:12:45 +0100 Subject: update Google Forms fix --- index.json | 13 +++++++------ src/google_forms.js | 37 ++++++++++++++++++++++++------------- 2 files changed, 31 insertions(+), 19 deletions(-) diff --git a/index.json b/index.json index b44c1de..b3c245b 100644 --- a/index.json +++ b/index.json @@ -196,7 +196,7 @@ "identifier": "google-forms-fix", "long_name": "Google Forms submission (incomplete) fix", "uuid": "23f51630-6118-4ef2-9709-2a1dba7ebb52", - "version": [2022, 2, 21], + "version": [2022, 3, 7], "revision": 1, "description": "Enable filling and submitting of Google Forms without nonfree JavaScript.", "dependencies": [], @@ -206,15 +206,16 @@ "identifier": "google-forms-fix", "long_name": "Google Forms submission (incomplete) fix", "uuid": "0aba91dc-e552-4276-a981-1a56d30f9058", - "version": [2022, 2, 21], + "version": [2022, 3, 7], "description": "Enable filling and submitting of Google Forms without nonfree JavaScript.", "payloads": { - // * https://old.reddit.com/search?q=url%3Adocs.google.com%2Fforms <- to get more testing links - // * https://docs.google.com/forms/d/e/1FAIpQLSeptahnx4tj-mr2QIzKiy1LN0HrZVR88-XwVtKDb33KbshaQA/viewform - // * https://docs.google.com/forms/d/e/1FAIpQLSeswHRJzUMWnCQPnaGHeB3xM7YyJdWMf2eMpHJOnetLEoeXmw/viewform - // * https://docs.google.com/forms/d/e/1FAIpQLSeptahnx4tj-mr2QIzKiy1LN0HrZVR88-XwVtKDb33KbshaQA/viewform + // * https://old.reddit.com/search?q=url%3Adocs.google.com%2Fforms <- to get testing links + // note: forms tend to expire quickly "https://docs.google.com/forms/d/**": { "identifier": "google-forms-fix" + }, + "https://docs.google.com/forms/u/1/d/**": { + "identifier": "google-forms-fix" } } }, { 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) -- cgit v1.2.3