// ==UserScript== // @name Google Forms Helper // @namespace https://github.com // @version 0.1 // @description Aids to solve google forms // @author erucix // @match https://docs.google.com/forms/* // @icon https://www.google.com/s2/favicons?sz=64&domain=google.com // @grant none // @license MIT // @downloadURL none // ==/UserScript== (function() { 'use strict'; const searchURL = "https://google.com/search?q="; const container = document.querySelectorAll(".geS5n"); container.forEach((element, index) => { let questionContainer = element.querySelector(".z12JJ"); let answersContainer = element.querySelectorAll(".nWQGrd"); let options = ""; let question = questionContainer.textContent; answersContainer.forEach((points) => { options += points.textContent + " \n"; }); let spanElement = document.createElement("span"); spanElement.innerHTML = ` SEARCH     COPY `; questionContainer.appendChild(spanElement); let copyButton = questionContainer.querySelector(".copyText"); copyButton.addEventListener("click", function () { navigator.clipboard.writeText(question + "\n" + options); copyButton.innerText = "Copied"; setTimeout(function(){ copyButton.innerText = "Copy"; },5000); }); let anotherSpan = document.createElement("span"); anotherSpan.innerHTML += `

GoogleAI Answer:


Waiting for answer...


`; element.appendChild(anotherSpan); }); var a = document.querySelectorAll(".geS5n"); a.forEach((element)=>{ let questionContainer = element.querySelector(".z12JJ"); let answersContainer = element.querySelectorAll(".nWQGrd"); let options = ""; let question = questionContainer.textContent; answersContainer.forEach((points) => { options += points.textContent + " \n"; }); fetch("https://generativelanguage.googleapis.com/v1beta3/models/text-bison-001:generateText?key=AIzaSyC_Z67CTkUzwhybPrPexMqxIdvL7F3xhM0", { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify({ prompt: { text: "Which of the following option is correct for this question?\n" + question.replace("COPY", "").replace("SEARCH", "") + "\n" + options, }, }), }) .then(response => response.json()) .then(data => { element.querySelector("#chatGPTAnswer").innerText = data.candidates[0].output; }) .catch(error => { element.querySelector("#chatGPTAnswer").innerText = "Failed to fetch answer."; }); }) })();