// ==UserScript==
// @name 환산주스탯 보스 배율 시간 표시
// @namespace local.maplescouter.boss-time
// @version 1.0.4
// @description 보스 배율 아래에 (n분 n초) 또는 (솔플 불가) 표시. 100%=20분 기준.
// @match https://maplescouter.com/*
// @run-at document-idle
// @grant none
// ==/UserScript==
(function () {
'use strict';
// 사이트의 '적용중인 보스 시간'도 20분으로 설정하세요.
const BASE_MINUTES = 20;
const ATTRIBUTE = 'data-ms-boss-minutes';
const PERCENT = /^s*((?:d{1,3}(?:,d{3})+|d+)(?:.d+)?)s*%s*$/;
const style = document.createElement('style');
style.textContent =
'[' + ATTRIBUTE + '] {' +
' white-space: nowrap;' +
' text-align: center;' +
'}' +
'[' + ATTRIBUTE + ']::after {' +
' content: attr(' + ATTRIBUTE + ');' +
' display: block;' +
' margin-top: 2px;' +
' line-height: 1.3;' +
' font-size: inherit;' +
' font-weight: inherit;' +
'}';
(document.head || document.documentElement).appendChild(style);
function update() {
const active = new Set();
if (/^/ko/result/?$/.test(location.pathname)) {
const images = document.querySelectorAll('img[alt="boss"]');
for (const image of images) {
const button = image.closest('button');
const card = button ? button.parentElement : null;
if (!card) continue;
for (const element of card.querySelectorAll('div')) {
if (element.children.length) continue;
const match = element.textContent.match(PERCENT);
if (!match) continue;
const percent = Number(match[1].replace(/,/g, ''));
const totalSeconds = Math.round(
BASE_MINUTES * 100 * 60 / percent
);
let label = '(계산 불가)';
if (percent > 0 && Number.isFinite(totalSeconds)) {
if (totalSeconds >= BASE_MINUTES * 60) {
label = '(솔플 불가)';
} else {
const minutes = Math.floor(totalSeconds / 60);
const seconds = totalSeconds % 60;
label = '(' + minutes + '분 ' + seconds + '초)';
}
}
active.add(element);
if (element.getAttribute(ATTRIBUTE) !== label) {
element.setAttribute(ATTRIBUTE, label);
}
}
}
}
const marked = document.querySelectorAll('[' + ATTRIBUTE + ']');
for (const element of marked) {
if (!active.has(element)) {
element.removeAttribute(ATTRIBUTE);
}
}
}
let timer;
const observer = new MutationObserver(function () {
if (timer !== undefined) return;
timer = setTimeout(function () {
timer = undefined;
update();
}, 100);
});
observer.observe(document.body, {
childList: true,
subtree: true,
characterData: true
});
window.addEventListener('popstate', update);
update();
})();