Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use this program? #1

Open
AlifBrahim opened this issue Apr 10, 2021 · 3 comments
Open

How to use this program? #1

AlifBrahim opened this issue Apr 10, 2021 · 3 comments
Labels
question Further information is requested

Comments

@AlifBrahim
Copy link

Hi developer. I had already installed your program on Tampermonkey. So, how to run it?
Thank you.
Regards,
Alif

@zerodytrash
Copy link
Owner

hi,

If you visit a Google form that expects exact values, the script will ask you if you want to pre-fill them.
Example Form: https://docs.google.com/forms/d/e/1FAIpQLSf1jIkFvckXSRmtWCZORzOQcQft846fEFMHj2tFDtmNBASyuQ/viewform

2021-04-10 16_51_32

If this does not happen, check if the script is activated.
2021-04-10 16_51_46

@zerodytrash zerodytrash added the question Further information is requested label Apr 10, 2021
@JustinGuestX6YT
Copy link

it didn't work

@CreateFor
Copy link

here use this script

// ==UserScript==
// @name Google Forms Quiz Solver
// @namespace https://zerody.one
// @Version 0.2
// @description This script tries to extract exact answer conditions from Google Forms and solve them
// @author ZerodyOne (https://github.com/zerodytrash/)
// @match https://docs.google.com/forms/*
// @grant none
// @run-at document-end
// ==/UserScript==

(function() {
'use strict';

// skip form if already filled by url params
if(location.href.indexOf("?entry.") > 0) return;

var inputAreas = document.querySelectorAll("div[data-params]");
var urlPrefillParams = new URLSearchParams();

inputAreas.forEach((inputArea) => {
    try {

        var areaParams = inputArea.getAttribute("data-params");
        var decodedAreaParams = JSON.parse("[" + areaParams.substr(areaParams.indexOf("["), areaParams.length));
        var questionParams = decodedAreaParams[0][4][0];
        var questionEntryId = questionParams[0];
        var validationParams = questionParams[4];

        // if validation disabled
        if(validationParams.length === 0) return;

        var validationRule = validationParams[0];
        var valueToFill = null;

        // type: number && match: equal to
        if(validationRule[0] === 1 && validationRule[1] === 5) {
            valueToFill = validationRule[2][0];
        }

        // type: text && match: contains
        if(validationRule[0] === 2 && validationRule[1] === 100) {
            valueToFill = validationRule[2][0];
        }

        if(valueToFill !== null) urlPrefillParams.set("entry." + questionEntryId, valueToFill);

    } catch(ex) {
        console.error("Param decoding failed", ex, inputArea);
    }
});

if(Array.from(urlPrefillParams).length > 0) {
    if(confirm("Found " + Array.from(urlPrefillParams).length + " exact values in form validation. Prefill form?")) {
        location.search = urlPrefillParams;
    }
}

})();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants