如何使用 Tampermonkey 填写 Google 表单的下拉列表和文本输入?

How to fill in Google Form's drop down and text inputs with Tampermonkey?

我正在尝试自动化由 Google Forms 托管的出勤表,但输入不是 HTML <input><select> 元素,所以我不是除了操作鼠标和键盘(我在 Selenium 中使用的一种方法)之外,确定如何更改它们。

基于快速高峰;你可以

let Form = document.querySelector('.freebirdFormviewerViewItemList');
let itemContainer = Form.querySelectorAll('.freebirdFormviewerViewNumberedItemContainer');

    itemContainer.forEach((element)=>{
// Your code here, you should in theory be doing deeper loops depending on how advanced you want this.
    });

在循环中,我们只需要找到我们想要的所有活动输入

itemContainer.forEach((element)=>{
    if(element.querySelector('.exportOuterCircle')) {
    console.log('we found ourselves a radio button but just one, we could go deeper with querySelector (and help of loops/etc)')
    }
});

这是一个有点大的任务,但还不错,只要确保 freebirdFormviewerViewNumberedItemContainer class 是正确的每个表单或你找到每页的模式 select这是快速循环的问题。

在循环中,您要查询 select 一个或多个(如果是,应用另一个循环)以找到您想要的选项。在单选按钮搜索上方的这个演示中,如果页面保持静态,你应该能够 grab/see 控制台弹出没有错误;

要设置这些值,在某些情况下 setAttribute/value/ 和其他修饰符一旦 selection 生成就很容易了。所以你已经知道点击了,所以单选按钮就是一个很好的例子。如有任何问题,请尝试在开发人员菜单中导航您的元素,如果 selections 正确下降则进行排序。

https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelector