// ==UserScript== // @name 安全教育平台自动答题 // @description 支持安全课程、专题活动 // @namespace https://greasyfork.org/users/197529 // @homepage https://greasyfork.org/scripts/372426 // @supportURL https://greasyfork.org/scripts/372426/feedback // @version 0.7.6 // @author kkocdko // @license Unlicense // @match *://*.xueanquan.com/* // @downloadURL none // ==/UserScript== 'use strict' const addFloatButton = initFloatButton() addFloatButton('自动答题', () => { document.querySelectorAll('[type=radio], [type=checkbox]').forEach(el => { if (!el.checked) { el.value = 1 el.click() } }) window.scrollTo(window.scrollX, document.documentElement.scrollHeight || document.body.scrollHeight) }) function initFloatButton () { return (document.addFloatButton = document.addFloatButton || (() => { const buttonBarShadow = document.createElement('div').attachShadow({ mode: 'open' }) buttonBarShadow.innerHTML = '' document.body.appendChild(buttonBarShadow.host) return (text, onclick) => { const button = document.createElement('button') button.textContent = text button.addEventListener('click', onclick) return buttonBarShadow.appendChild(button) } })()) }