使用JavaScript自动化Microsoft表单填充

时间:2020-06-30 10:58:26

标签: javascript forms microsoft-forms

我有一个要自动化的Microsoft表单,因为我打算创建一个chrome扩展名,以便每天定期提交该表单 表单只有两个字段, 一个是文本字段

enter image description here

第二个是带有星星的评分控件

enter image description here

对于文本字段,我可以直接使用document.getElementById('name').value='name',但是对于星星来说,它有点棘手,因为它们没有按钮或可以触发的事件

以下是星星的HTML

<div
  class="rateit margin-left office-form-theme-primary-foreground rateit-font"
  data-rateit-icon=""
  data-rateit-iconforempty=""
  data-rateit-mode="font"
  data-rateit-marginleft="4"
  data-rateit-marginright="4"
  data-rateit-starwidth="24"
  data-rateit-max="5"
  data-rateit-step="1"
  data-rateit-resetable="false"
  data-rateit-ispreset="true"
  style="font-size: 24px;"
  title="2 Stars"
  data-rateit-value="2"
>
  <button
    id="rateit-reset-5"
    type="button"
    data-role="none"
    class="rateit-reset"
    aria-label="reset rating"
    aria-controls="rateit-range-5"
    style="float: left; display: none;"
  >
    <span></span>
  </button>
  <div
    id="rateit-range-5"
    class="rateit-range"
    tabindex="0"
    role="slider"
    aria-owns="rateit-reset-5"
    aria-valuemin="0"
    aria-valuemax="5"
    aria-valuenow="2"
    aria-labelledby="question15-title question15-required question15-questiontype l5"
  >
    <div class="rateit-empty">
      <span style="margin: 0px 4px;"></span
      ><span style="margin: 0px 4px;"></span
      ><span style="margin: 0px 4px;"></span
      ><span style="margin: 0px 4px;"></span
      ><span style="margin: 0px 4px;"></span>
    </div>
    <div class="rateit-selected" style="width: 64px; display: flex;">
      <span style="margin: 0px 4px;"></span
      ><span style="margin: 0px 4px;"></span
      ><span style="margin: 0px 4px;"></span
      ><span style="margin: 0px 4px;"></span // tried to trigger a click on this via JS , but no luck
      ><span style="margin: 0px 4px;"></span>
    </div>
    <div class="rateit-hover" style="width: 0px; display: none;">
      <span style="margin: 0px 4px;"></span
      ><span style="margin: 0px 4px;"></span
      ><span style="margin: 0px 4px;"></span
      ><span style="margin: 0px 4px;"></span
      ><span style="margin: 0px 4px;"></span>
    </div>
  </div>
</div>

我尝试更新.rateit> data-rateit-value.rateit-range> aria-valuenow,但是没有运气 还尝试通过触发跨度上的点击事件来产生星星但没有运气

还有其他方法可以触发点击并更新值

0 个答案:

没有答案
相关问题