您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
在目标元素内创建新按钮,点击所有id格式为rdoxx01的input元素并在txtXXX输入框内输入文字
当前为
// ==UserScript== // @name 自动评教 // @namespace http://tampermonkey.net/ // @version 1.0 // @description 在目标元素内创建新按钮,点击所有id格式为rdoxx01的input元素并在txtXXX输入框内输入文字 // @author You // @match https://yjsy.ustb.edu.cn/* // @grant none // ==/UserScript== (function () { 'use strict'; // 用户可以修改为rdoxx01、rdoxx02、rdoxx03、rdoxx04、rdoxx05其中的一个 // 01-05分别代表◎优秀 100分 ◎良好 85分 ◎一般 75分 ◎较差 60分 ◎很差 40分 const INPUT_ID_PATTERN = 'rdoxx01'; // 创建并插入样式 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^="${INPUT_ID_PATTERN.slice(0, -4)}"][id$="${INPUT_ID_PATTERN.slice(-2)}"]`); inputElements.forEach(function (inputElement) { if (new RegExp(`^${INPUT_ID_PATTERN.slice(0, -4)}\\d{2}${INPUT_ID_PATTERN.slice(-2)}$`).test(inputElement.id)) { inputElement.click(); } }); } function fillTextInputs() { var textInputs = document.querySelectorAll('textarea[id^="txt"]'); textInputs.forEach(function (textInput) { if (/^txt\d{2,3}$/.test(textInput.id)) { textInput.value = '非常好没有意见'; } }); } window.addEventListener('load', function () { var targetEl = document.querySelector('td[align="right"][style*="padding-bottom:10px;"]'); if (targetEl) { createButton(targetEl); } }, false); })();