-
Notifications
You must be signed in to change notification settings - Fork 0
/
tampermonkeyexample.js
82 lines (66 loc) · 2.48 KB
/
tampermonkeyexample.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
// ==UserScript==
// @name Google form auto filler
// @namespace http://tampermonkey.net/
// @version 2024-05-10
// @description https://github.com/Kirize14/GoogleFormFiller
// @author Kirize14
// @match https://docs.google.com/forms/d/e/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=google.com
// @grant none
// ==/UserScript==
(function() {
'use strict';
/*
Config Zone
*/
let checkboxToClick = [0];
let radioToClick = [0];
let autoSubmit = false;
// If form are not accessible due to high traffic then reload
if(document.querySelectorAll('title')[0].innerText == "Too Many Requests")location.reload();
let answerBox = document.querySelectorAll("input:enabled, select:enabled, textarea:enabled");
let questionBox = document.querySelectorAll("input:enabled, select:enabled, textarea:enabled");
for (let i = 0; i < questionBox.length; i++) {
let question = questionBox[i].parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.querySelector('div').innerText;
let answer;
//Question Zone
//Only edit between this line
if (['ast', 'urname', 'สกุล'].some(keyword => question.includes(keyword))) {
answer = 'This goes the last name';
}
if (['assport', 'พาส'].some(keyword => question.includes(keyword))) {
answer = "Here's go the passport number";
}
//End of question Zone
if (answer !== '') {
answerBox[i].focus();
document.execCommand('selectAll', false, null);
document.execCommand('insertText', false, answer);
}
if(questionBox.length-1 == i)
{
checkBox();
}
}
async function checkBox()
{
for(let i = 0 ; i < checkboxToClick.length ; i++)
{
let checkboxToClick = document.querySelectorAll('div[role="checkbox"]')[i]
if(checkboxToClick)checkboxToClick.click();
}
for(let i = 0 ; i < radioToClick.length ; i++)
{
let radioToClick = document.querySelectorAll('div[role="radio"]')[i]
if(radioToClick)radioToClick.click();
}
if(autoSubmit == true)
{
let submit = document.querySelectorAll("span");
for (let i = 0; i < submit.length; i++) {
if(submit[i].innerText == "Submit" || submit[i].innerText == "ส่ง") submit[i].click();
if(submit[i].innerText == "ถัดไป" || submit[i].innerText == "Next") submit[i].click();
}
}
}
})();