慕码人2483693
这是一个肮脏的脚本,可能是一个起点。它仅适用于您作为示例提供的特定表单。它用于document.querySelector定位表单元素。只要您打开表单,它就会填写、提交、返回、提交,一遍又一遍。要使用它:在 Google Chrome 中安装TamperMonkey扩展单击浏览器中出现的图标,选择“仪表板”创建一个新脚本,将所有内容替换为下面的代码Ctrl + S 保存在选项卡中打开表单并观察它的工作代码:// ==UserScript==// @name GoogleForm Spammer// @namespace http://tampermonkey.net/// @version 0.1// @description Spam a Google Form// @author You// @match https://docs.google.com/forms/*// @grant unsafeWindow// ==/UserScript==(function() { window.addEventListener('load', function() { if (window.location.pathname.indexOf('/forms/d') === 0) { // If we're on the form page submitRandomForm(); } else if (window.location.pathname.indexOf('/forms/u') === 0) { // If we're on the "submitted" page goBackToForm(); } function submitRandomForm() { // Size var radios = document.querySelectorAll(".appsMaterialWizToggleRadiogroupRadioButtonContainer"), radioIndex = Math.floor(Math.random() * radios.length); radios[radioIndex].click(); // Print var checkboxes = document.querySelectorAll(".appsMaterialWizTogglePapercheckboxCheckbox"), checkboxIndex = Math.floor(Math.random() * checkboxes.length); checkboxes[checkboxIndex].click(); // Age (between 16 and 45) var age = Math.floor(Math.random() * 30) + 16; document.querySelector(".quantumWizTextinputPaperinputInput").value = age; // Submit document.querySelector(".freebirdFormviewerViewCenteredContent .appsMaterialWizButtonPaperbuttonLabel").click(); } function goBackToForm() { window.location.href = 'https://docs.google.com/forms/d/e/1FAIpQLSd7GueJGytOiQpkhQzo_dCU0oWwbk3L1htKblBO1m14VHSpHw/viewform'; } });})();这是一个更清洁的方法。您在顶部声明表单 URL、表单字段,并且对于其中的一些,一个函数将根据您的需要返回一个随机值。要尝试这个,请保存该脚本,然后尝试访问此表单:// ==UserScript==// @name GoogleForm Spammer// @namespace http://tampermonkey.net/// @version 0.1// @description Spam a Google Form// @author You// @match https://docs.google.com/forms/*// @grant none// ==/UserScript==var formUrl = 'https://docs.google.com/forms/d/e/1FAIpQLSdQ9iT7isDU8IIbyg-wowB-9HGzyq-xu2NyzsOeG0j8fhytmA/viewform';var formSchema = [ {type: 'radio'}, // A {type: 'radio'}, // B {type: 'checkbox'}, // C {type: 'checkbox'}, // D {type: 'short_text', func: generateAnswerE }, // E {type: 'paragraph', func: generateParagraph }, // F];function generateAnswerE() { // Let's say we want a random number return Math.floor(Math.random() * 30) + 16;}function generateParagraph() { // Just for the example return "Hello world";}(function() { window.addEventListener('load', function() { if (window.location.pathname.indexOf('/forms/d') === 0) { // If we're on the form page submitRandomForm(); } else if (window.location.pathname.indexOf('/forms/u') === 0) { // If we're on the "submitted" page window.location.href = formUrl; } function submitRandomForm() { var formItems = document.querySelectorAll('.freebirdFormviewerViewItemsItemItem'); for (var i = 0; i < formSchema.length; i++) { var field = formSchema[i], item = formItems[i]; switch(field.type) { case 'radio': var radios = item.querySelectorAll(".appsMaterialWizToggleRadiogroupRadioButtonContainer"), radioIndex = Math.floor(Math.random() * radios.length); radios[radioIndex].click(); break; case 'checkbox': var checkboxes = item.querySelectorAll(".appsMaterialWizTogglePapercheckboxCheckbox"), checkboxIndex = Math.floor(Math.random() * checkboxes.length); checkboxes[checkboxIndex].click(); break; case 'short_text': item.querySelector(".quantumWizTextinputPaperinputInput").value = field.func(); break; case 'paragraph': item.querySelector(".quantumWizTextinputPapertextareaInput").value = field.func(); break; } } // Submit document.querySelector(".freebirdFormviewerViewCenteredContent .appsMaterialWizButtonPaperbuttonLabel").click(); } });})();