本帖最后由 liyitong 于 2025-5-22 12:32 编辑
众所周知,知网的毕业设计管理系统得点太多太多下。
结合
https://www.52pojie.cn/thread-2030433-1-1.html
的帖子,在网页上添加一个button,点击一下就执行点一遍所有目标选择框。该代码在脚本猫上执行无误。[JavaScript] 纯文本查看 复制代码 // ==UserScript==
//@name 一键审核毕业答辩申请
//@namespace https://www.52pojie.cn/home.php?mod=space&uid=1796855
//@version 1.2
//@description co2.cnki
//@AuThor liyitong
//@match https://co2.cnki.net/Main.html*
//@grant GM_xmlhttpRequest
//@license MIT
// ==/UserScript==
(function () {
'use strict';
// 定义要点击的 input 的 id 列表
const ids = ["rdoPass0",
"radio_1581_column0820",
"radio_1582_column0830",
"radio_1583_column0840",
"radio_1584_column0850",
"radio_1585_column0860",
"radio_1586_column0870",
"radio_1587_column0880",
"radio_1588_column0891",
"radio_1589_column0901",
"radio_1590_column0911",
"radio_1591_column0921"]; // 根据实际情况修改
// 创建按钮并添加到页面
const button = document.createElement('button');
button.innerText = '一键审核';
button.style.position = 'fixed';
button.style.bottom = '20px';
button.style.right = '20px';
button.style.zIndex = '1000';
button.style.padding = '10px 20px';
button.style.backgroundColor = '#ff4d4d';
button.style.color = '#fff';
button.style.border = 'none';
button.style.borderRadius = '5px';
button.style.cursor = 'pointer';
document.body.appendChild(button);
function yijianshenhe() {
// 将 HTMLCollection 转换为数组
const iframes = Array.from(document.getElementsByTagName('iframe'));
// 遍历所有 iframe
iframes.forEach(iframe => {
// 检查 iframe 的 title 是否为 "审核答辩详情"
if (iframe.title === "审核答辩详情") {
// 确保 iframe 的内容已经加载
try {
// 获取 iframe 的文档对象
const iframeDoc = iframe.contentDocument;
// 遍历 id 列表
ids.forEach(id => {
// 查找指定 id 的 input 元素
const inputElement = iframeDoc.getElementById(id);
// 检查元素是否存在
if (inputElement) {
// 模拟点击操作
inputElement.click();
} else {
console.log(`Element with id "${id}" not found in the iframe.`);
}
});
} catch (error) {
console.error('Error accessing iframe content:', error);
}
}
});
}
button.addEventListener('click', () => {
yijianshenhe();
});
})(); |