Project

General

Profile

« Previous | Next » 

Revision c6505d41

Added by koszko over 1 year ago

update Google Forms fix

View differences:

index.json
196 196
	"identifier":   "google-forms-fix",
197 197
	"long_name":    "Google Forms submission (incomplete) fix",
198 198
	"uuid":         "23f51630-6118-4ef2-9709-2a1dba7ebb52",
199
	"version":      [2022, 2, 21],
199
	"version":      [2022, 3, 7],
200 200
	"revision":     1,
201 201
	"description":  "Enable filling and submitting of Google Forms without nonfree JavaScript.",
202 202
	"dependencies": [],
......
206 206
	"identifier":   "google-forms-fix",
207 207
	"long_name":    "Google Forms submission (incomplete) fix",
208 208
	"uuid":	        "0aba91dc-e552-4276-a981-1a56d30f9058",
209
	"version":      [2022, 2, 21],
209
	"version":      [2022, 3, 7],
210 210
	"description":  "Enable filling and submitting of Google Forms without nonfree JavaScript.",
211 211
	"payloads": {
212
	    // * https://old.reddit.com/search?q=url%3Adocs.google.com%2Fforms <- to get more testing links
213
	    // * https://docs.google.com/forms/d/e/1FAIpQLSeptahnx4tj-mr2QIzKiy1LN0HrZVR88-XwVtKDb33KbshaQA/viewform
214
	    // * https://docs.google.com/forms/d/e/1FAIpQLSeswHRJzUMWnCQPnaGHeB3xM7YyJdWMf2eMpHJOnetLEoeXmw/viewform
215
	    // * https://docs.google.com/forms/d/e/1FAIpQLSeptahnx4tj-mr2QIzKiy1LN0HrZVR88-XwVtKDb33KbshaQA/viewform
212
	    // * https://old.reddit.com/search?q=url%3Adocs.google.com%2Fforms <- to get testing links
213
	    // note: forms tend to expire quickly
216 214
	    "https://docs.google.com/forms/d/**": {
217 215
		"identifier": "google-forms-fix"
216
	    },
217
	    "https://docs.google.com/forms/u/1/d/**": {
218
		"identifier": "google-forms-fix"
218 219
	    }
219 220
	}
220 221
    }, {
src/google_forms.js
24 24
 */
25 25

  
26 26
var form = document.forms[0];
27

  
28
/* Fix form fields. */
27 29
for (let div of form.querySelectorAll('div[data-params]')) {
28 30
    var data = JSON.parse('[' + div.dataset.params.substring(4));
29 31
    var name = 'entry.' + data[0][4][0][0];
30
    var input = div.querySelector('input');
32
    var input = div.querySelector('input, textarea');
31 33

  
32 34
    if (!input) {
33 35
	console.error(`cannot enable input ${name}`, div);
34 36
	continue;
35 37
    }
36 38

  
37
    if (input.name === name + '_sentinel') { // Radio
38
	for (const input_div of div.querySelectorAll('.appsMaterialWizToggleRadiogroupEl')) {
39
    if (input.name === name + '_sentinel') {
40
	/* Handle radio buttons. */
41
	for (const input_div of div.querySelectorAll('[data-value]')) {
39 42
	    const new_radio = document.createElement('input');
40 43
	    new_radio.type = 'radio';
41 44
	    new_radio.name = name;
......
45 48
    } else {
46 49
	input.removeAttribute('disabled');
47 50
	input.name = name;
51

  
52
	/* Enlarge textareas and make them stand out from mere input fields. */
53
	if (input.tagName === "TEXTAREA") {
54
	    input.style.height = "8em";
55
	    input.style.overflowY = "scroll";
56
	}
48 57
    }
49 58
}
50 59

  
51
for (div of document.querySelectorAll('.quantumWizTextinputPaperinputPlaceholder'))
52
    div.remove();
60
/* Remove placeholders in text input fields and textareas. */
61
document.querySelectorAll('[jsname=LwH6nd]').forEach(n => n.remove());
53 62

  
63
/* Enable the form sumbission button (if any). */
64
for (const submit_but of document.querySelectorAll('[jsname=M2UYVd]'))
65
    submit_but.addEventListener("click", () => form.submit());
66

  
67
/* Enable the "next page" button (if any). */
54 68
function goToNext()
55 69
{
56 70
    var next = document.createElement('input');
......
61 75
    form.submit();
62 76
}
63 77

  
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);
78
for (const next_but of document.querySelectorAll('[jsname=OCpkoe]'))
79
    next_but.addEventListener("click", goToNext);
71 80

  
72
// TODO: back, instate previous entries, fix form parts that still don't work
81
// TODO:
82
// * support "back" with instatiation of previous entries
83
// * find and fix form parts that still don't work (if any)

Also available in: Unified diff