Edit OJ评测结果魔改器.user.js
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
// ==UserScript==
|
||||
// @name OJ评测结果魔改器
|
||||
// @namespace https://zymsite.ink/
|
||||
// @version 1.0.0
|
||||
// @version 1.0.1
|
||||
// @description 胡乱修改评测结果显示页面
|
||||
// @author happyZYM
|
||||
// @match https://acm.sjtu.edu.cn/OnlineJudge/*
|
||||
@ -11,20 +11,20 @@
|
||||
(function() {
|
||||
'use strict';
|
||||
function replaceTextContent(node, targetText, replacementText) {
|
||||
if (node.nodeType === Node.TEXT_NODE) {
|
||||
// 如果是文本节点,并且文本内容包含 `Accepted`,则替换成新的文本
|
||||
node.nodeValue = node.nodeValue.replace(targetText, replacementText);
|
||||
} else {
|
||||
// 如果节点是元素节点,需要检查它的文本内容
|
||||
node.childNodes.forEach(childNode => replaceTextContent(childNode, targetText, replacementText));
|
||||
if (node.nodeType === Node.TEXT_NODE) {
|
||||
// 如果是文本节点,并且文本内容包含 `Accepted`,则替换成新的文本
|
||||
node.nodeValue = node.nodeValue.replace(targetText, replacementText);
|
||||
} else {
|
||||
// 如果节点是元素节点,需要检查它的文本内容
|
||||
node.childNodes.forEach(childNode => replaceTextContent(childNode, targetText, replacementText));
|
||||
|
||||
// 检查元素的自身文本内容
|
||||
if (node.nodeType === Node.ELEMENT_NODE) {
|
||||
if (node.hasChildNodes() === false && node.textContent.includes(targetText)) {
|
||||
node.textContent = node.textContent.replace(targetText, replacementText);
|
||||
}
|
||||
}
|
||||
}
|
||||
// 检查元素的自身文本内容
|
||||
if (node.nodeType === Node.ELEMENT_NODE) {
|
||||
if (node.hasChildNodes() === false && node.textContent.includes(targetText)) {
|
||||
node.textContent = node.textContent.replace(targetText, replacementText);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 从网页的 body 元素开始,替换所有文本内容为 `Accepted` 的节点
|
||||
|
Reference in New Issue
Block a user