Converts FMInside 0–100 attributes to 1–20 scale. 99 treated as 100 → 20. Prevent double conversion.
当前为
// ==UserScript==
// @name FMInside Attribute Fixer (with 99 → 20)
// @namespace http://tampermonkey.net/
// @license MIT
// @version 1.6
// @description Converts FMInside 0–100 attributes to 1–20 scale. 99 treated as 100 → 20. Prevent double conversion.
// @match https://fminside.net/players/*
// @grant none
// @run-at document-idle
// ==/UserScript==
(function () {
'use strict';
function convertToFMScale(value) {
// Treat 99 as 100
if (value === 99) {
value = 100;
}
return Math.round(value / 5);
}
function convertAttributes() {
const elements = document.querySelectorAll('*');
elements.forEach(el => {
if (
el.children.length === 0 &&
el.textContent.trim().match(/^\d{1,3}$/) &&
!el.hasAttribute('data-fmconverted')
) {
let val = parseInt(el.textContent.trim(), 10);
// Only convert if divisible by 5 between 5 and 100, OR if val is 99 (special case)
if ((val >= 5 && val <= 100 && val % 5 === 0) || val === 99) {
const converted = convertToFMScale(val);
if (converted >= 1 && converted <= 20) {
el.textContent = converted.toString();
el.setAttribute('data-fmconverted', 'true');
}
}
}
});
}
convertAttributes();
const observer = new MutationObserver(convertAttributes);
observer.observe(document.body, { childList: true, subtree: true });
})();