您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
在目标元素内创建新按钮,点击所有id格式为rdoxx01的input元素并在txtXXX输入框内输入文字
// ==UserScript== // @name 自动评教 // @namespace http://tampermonkey.net/ // @version 1.1 // @description 在目标元素内创建新按钮,点击所有id格式为rdoxx01的input元素并在txtXXX输入框内输入文字 // @author You // @match https://yjsy.ustb.edu.cn/* // @grant none // ==/UserScript== (function () { 'use strict'; var INPUT_ID_PATTERN = 'rdoxx01'; var defaultText = '非常好没有意见'; var style = document.createElement('style'); style.textContent = ` .marginright20 { margin-right: 20px; } .floatright { float: right; } .btn-primary { background: #00A7F7; border: 1px #00A7F7 solid; color: #fff; } button, .btn-default { font-size: 14px; line-height: 1.2; padding: 9px 20px; outline: none; background: #fff; border: 1px #77909D solid; color: #77909D; border-radius: 50px; cursor: pointer; } button, input, select, textarea { font-family: inherit; font-size: inherit; line-height: inherit; margin: 0; font: inherit; color: inherit; word-spacing: normal; text-transform: none; text-indent: 0px; text-shadow: none; } input, button, select, textarea { outline: none; } `; document.head.appendChild(style); function createButton(targetElement) { var newButton = document.createElement('button'); newButton.textContent = '评价'; newButton.type = 'button'; newButton.classList.add('btn-primary', 'floatright', 'marginright20'); newButton.onclick = function () { clickInputElements(); fillTextInputs(); }; targetElement.appendChild(newButton); } function clickInputElements() { var inputElements = document.querySelectorAll(`input[id^="rdo"][id$="${INPUT_ID_PATTERN.slice(-2)}"]`); console.log(`找到 ${inputElements.length} 个符合条件的 input 元素`); inputElements.forEach(function (inputElement) { inputElement.click(); }); console.log('所有符合条件的 input 元素已点击'); } function fillTextInputs() { var textInputs = document.querySelectorAll('textarea[id^="txt"]'); console.log(`找到 ${textInputs.length} 个符合条件的 textarea 元素`); textInputs.forEach(function (textInput) { if (/^txt\d{2,3}$/.test(textInput.id)) { textInput.value = defaultText; } }); } window.addEventListener('load', function () { var targetEl = document.querySelector('td[align="right"][style*="padding-bottom:10px;"]'); if (targetEl) { createButton(targetEl); } }, false); })();