1
|
/**
|
2
|
* SPDX-License-Identifier: Apache-2.0
|
3
|
*
|
4
|
* (Incomplete) Fix for Google Forms
|
5
|
*
|
6
|
* Copyright © 2021 jahoti <jahoti@tilde.team>
|
7
|
* Copyright 2022 Wojtek Kosior <koszko@koszko.org>
|
8
|
*
|
9
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
10
|
* you may not use this file except in compliance with the License.
|
11
|
* You may obtain a copy of the License at
|
12
|
*
|
13
|
* http://www.apache.org/licenses/LICENSE-2.0
|
14
|
*
|
15
|
* Unless required by applicable law or agreed to in writing, software
|
16
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
17
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
18
|
* See the License for the specific language governing permissions and
|
19
|
* limitations under the License.
|
20
|
*
|
21
|
* I, Wojtek Kosior, thereby promise not to sue for violation of this file's
|
22
|
* license. Although I request that you do not make use of this code in a way
|
23
|
* incompliant with the license, I am not going to enforce this in court.
|
24
|
*/
|
25
|
|
26
|
var form = document.forms[0];
|
27
|
for (let div of form.querySelectorAll('div[data-params]')) {
|
28
|
var data = JSON.parse('[' + div.dataset.params.substring(4));
|
29
|
var name = 'entry.' + data[0][4][0][0];
|
30
|
var input = div.querySelector('input');
|
31
|
|
32
|
if (!input) {
|
33
|
console.error(`cannot enable input ${name}`, div);
|
34
|
continue;
|
35
|
}
|
36
|
|
37
|
if (input.name === name + '_sentinel') { // Radio
|
38
|
for (const input_div of div.querySelectorAll('.appsMaterialWizToggleRadiogroupEl')) {
|
39
|
const new_radio = document.createElement('input');
|
40
|
new_radio.type = 'radio';
|
41
|
new_radio.name = name;
|
42
|
new_radio.value = input_div.getAttribute("data-value");
|
43
|
input_div.replaceWith(new_radio);
|
44
|
}
|
45
|
} else {
|
46
|
input.removeAttribute('disabled');
|
47
|
input.name = name;
|
48
|
}
|
49
|
}
|
50
|
|
51
|
for (div of document.querySelectorAll('.quantumWizTextinputPaperinputPlaceholder'))
|
52
|
div.remove();
|
53
|
|
54
|
function goToNext()
|
55
|
{
|
56
|
var next = document.createElement('input');
|
57
|
next.type = 'hidden';
|
58
|
next.name = 'continue';
|
59
|
next.value = '1';
|
60
|
form.appendChild(next);
|
61
|
form.submit();
|
62
|
}
|
63
|
|
64
|
const submit_selector = ".freebirdFormviewerViewNavigationSubmitButton";
|
65
|
const next_selector = ".freebirdFormviewerViewNavigationNoSubmitButton";
|
66
|
for (const but_div of document.querySelectorAll(submit_selector))
|
67
|
but_div.addEventListener("click", () => form.submit());
|
68
|
|
69
|
for (const but_div of document.querySelectorAll(next_selector))
|
70
|
but_div.addEventListener("click", goToNext);
|
71
|
|
72
|
// TODO: back, instate previous entries, fix form parts that still don't work
|