Dynamically sets threshold to and hides higher scores on nrtool.to/history pages
当前为
// ==UserScript==
// @name NRTool Dynamic Score Filter
// @namespace http://tampermonkey.net/
// @version 1.2
// @description Dynamically sets threshold to and hides higher scores on nrtool.to/history pages
// @author ZaZaZa
// @match https://nrtool.to/nrtool/history/*
// @grant none
// @license MIT
// ==/UserScript==
(function() {
'use strict';
function filterResults() {
const captions = document.querySelectorAll('.item__caption');
if (captions.length === 0) {
return;
}
const scores = [];
captions.forEach(caption => {
const text = caption.textContent.trim();
const match = text.match(/^(\d+\.\d+)/);
if (match) {
scores.push(parseFloat(match[1]));
}
});
if (scores.length === 0) {
return;
}
const minScore = Math.min(...scores);
const threshold = minScore + 0.07;
let hiddenCount = 0;
captions.forEach(caption => {
const text = caption.textContent.trim();
const match = text.match(/^(\d+\.\d+)/);
if (match) {
const number = parseFloat(match[1]);
if (number > threshold) {
const fullItem = caption.closest('.sim-item');
if (fullItem && fullItem.style.display !== 'none') {
fullItem.style.display = 'none';
hiddenCount++;
}
}
}
});
}
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', filterResults);
} else {
filterResults();
}
const observer = new MutationObserver(function(mutations) {
let shouldRefilter = false;
mutations.forEach(function(mutation) {
if (mutation.type === 'childList' && mutation.addedNodes.length > 0) {
shouldRefilter = true;
}
});
if (shouldRefilter) {
setTimeout(filterResults, 500);
}
});
observer.observe(document.body, { childList: true, subtree: true });
})();