午安农场被偷记录统计
// ==UserScript==
// @name 被偷记录
// @namespace http://tampermonkey.net/
// @version 2024-08-06
// @description try to take over the world!
// @author You
// @match https://workspace.yuimeta.com/
// @icon https://www.google.com/s2/favicons?sz=64&domain=yuimeta.com
// @grant none
// ==/UserScript==
(function() {
'use strict';
function countAndDisplayTableRows() {
let xpath = '/html/body/div/div/div[8]/div/div[2]/table';
let result = document.evaluate(xpath, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null);
let table = result.singleNodeValue;
let targetDivs = document.querySelectorAll('div.flex.space-between.m1');
let targetDiv = Array.from(targetDivs).find(div => div.textContent.includes('日志'));
if (targetDiv) {
let countDiv = document.createElement('div');
function updateCount() {
if (table) {
let rows = table.querySelectorAll('tr');
let count = rows.length - 1;
countDiv.textContent = `被偷记录: ${count}`;
} else {
countDiv.textContent = '被偷记录: 0';
}
}
let observer = new MutationObserver(updateCount);
observer.observe(table, { childList: true, subtree: true });
// 设置样式
countDiv.style.color = 'red';
countDiv.style.marginLeft = '10px';
countDiv.style.marginRight = '10px';
countDiv.style.fontFamily = 'pix';
countDiv.style.whiteSpace = 'nowrap';
let logDiv = targetDiv.querySelector('div');
targetDiv.insertBefore(countDiv, logDiv.nextSibling);
} else {
console.log('目标 <div> 元素未找到。');
}
}
window.addEventListener('load', countAndDisplayTableRows);
})();
油猴脚本,大佬快来修改一下,吊毛歪油爱不乐意做统计。有没有大佬来做一下分类,根据小偷来分类
-
午安农场
he tui~