diff options
author | Wojtek Kosior <koszko@koszko.org> | 2022-02-21 14:03:11 +0100 |
---|---|---|
committer | Wojtek Kosior <koszko@koszko.org> | 2022-02-21 14:03:11 +0100 |
commit | bac96457a5b53a3f5fa5857e108e9e32515bb02b (patch) | |
tree | c0db5658a7201146e729bef85aecbca2bf1f6caa /src/google_forms.js | |
parent | c9ea962d4703fdc33fb5af6670383b721e8be3f9 (diff) | |
download | hydrilla-fixes-bundle-bac96457a5b53a3f5fa5857e108e9e32515bb02b.tar.gz hydrilla-fixes-bundle-bac96457a5b53a3f5fa5857e108e9e32515bb02b.zip |
improve some of the fixes and add sample URLs for testing
Diffstat (limited to 'src/google_forms.js')
-rw-r--r-- | src/google_forms.js | 40 |
1 files changed, 23 insertions, 17 deletions
diff --git a/src/google_forms.js b/src/google_forms.js index 5d8826d..54c1a04 100644 --- a/src/google_forms.js +++ b/src/google_forms.js @@ -4,6 +4,7 @@ * (Incomplete) Fix for Google Forms * * Copyright © 2021 jahoti <jahoti@tilde.team> + * Copyright 2022 Wojtek Kosior <koszko@koszko.org> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,6 +17,10 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. + * + * I, Wojtek Kosior, thereby promise not to sue for violation of this file's + * license. Although I request that you do not make use of this code in a way + * incompliant with the license, I am not going to enforce this in court. */ var form = document.forms[0]; @@ -24,13 +29,18 @@ for (let div of form.querySelectorAll('div[data-params]')) { var name = 'entry.' + data[0][4][0][0]; var input = div.querySelector('input'); + if (!input) { + console.error(`cannot enable input ${name}`, div); + continue; + } + if (input.name === name + '_sentinel') { // Radio - for (input of div.querySelectorAll('.appsMaterialWizToggleRadiogroupElContainer')) { - div = document.createElement('input'); - div.type = 'radio'; - div.name = name; - div.value = input.nextElementSibling.innerText.trim(); - input.parentNode.replaceChild(div, input); + for (const input_div of div.querySelectorAll('.appsMaterialWizToggleRadiogroupEl')) { + const new_radio = document.createElement('input'); + new_radio.type = 'radio'; + new_radio.name = name; + new_radio.value = input_div.getAttribute("data-value"); + input_div.replaceWith(new_radio); } } else { input.removeAttribute('disabled'); @@ -51,16 +61,12 @@ function goToNext() form.submit(); } -for (div of document.querySelectorAll('.freebirdFormviewerViewNavigationNoSubmitButton')) { - input = document.createElement('button'); +const submit_selector = ".freebirdFormviewerViewNavigationSubmitButton"; +const next_selector = ".freebirdFormviewerViewNavigationNoSubmitButton"; +for (const but_div of document.querySelectorAll(submit_selector)) + but_div.addEventListener("click", () => form.submit()); - data = div.innerText.trim(); - input.innerText = data; - if (data.toLowerCase() === 'next') - input.onclick = goToNext; - else if (data.toLowerCase() === 'submit') - input.type = 'submit'; - div.parentNode.replaceChild(input, div); -} +for (const but_div of document.querySelectorAll(next_selector)) + but_div.addEventListener("click", goToNext); -// TODO: back, instate previous entries +// TODO: back, instate previous entries, fix form parts that still don't work |