感谢这个论坛的帮助,我能够让我的代码工作:
// ==UserScript==
// @name PARINGO
// @description Auto select rpt radio button
// @namespace PARINGO
// @include https://docs.google.com/spreadsheet/viewform?formkey=dG1fdUU1bTR5R1l3dmtGS095QVYxZlE6MQ
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
// @grant GM_addStyle
// @version 1
// ==/UserScript==
/*- The @grant directive is needed to work around a design change introduced
in GM 1.0. It restores the sandbox.
*/
//-- Note that :contains() is case-sensitive
var questionLabel = $(
"label.ss-q-title:contains('How much is 1+1') ~ ul.ss-choices"
).first ().find ("input[type=radio][value=2]");
questionLabel.prop ('checked', true);
var questionLabel = $(
"label.ss-q-title:contains('How much is 4+2') ~ ul.ss-choices"
).first ().find ("input[type=radio][value=6]");
questionLabel.prop ('checked', true);
制作此脚本的原因是检查标签并标记正确答案。但如果响应由两个或多个单独的单词组成。没有作品,例如:
var questionLabel = $(
"label.ss-q-title:contains('How much is 4+2') ~ ul.ss-choices"
).first ().find ("input[type=radio][value=dog crazy]");
questionLabel.prop ('checked', true);
这适用于谷歌文档中的表单: Form Google Docs
任何人都可以告诉我该值如何接受单独的单词?
("input[type=radio][value=dog crazy]")