微件:GF立绘切换
来自OGAS数据中枢
更多操作
<script> (function () {
function initSwitcher() {
document.querySelectorAll('.gf-infobox-new').forEach(function (box) {
if (box.dataset.ready) return;
box.dataset.ready = '1';
var container = box.querySelector('.gf-image-container');
var thumbs = box.querySelectorAll('.gf-thumb-item');
if (!container || thumbs.length < 1) return;
thumbs.forEach(function (thumb) {
thumb.addEventListener('click', function () {
if (thumb.classList.contains('active')) return;
var src = thumb.dataset.src;
if (!src) return;
var oldImg = container.querySelector('img');
if (oldImg) {
oldImg.style.opacity = '0';
}
setTimeout(function () {
container.innerHTML = '<img src="' + src + '" style="max-width:100%;max-height:450px;object-fit:contain;opacity:0;transition:opacity 0.3s;height:auto;width:auto;">';
var newImg = container.querySelector('img');
if (newImg) {
newImg.onload = function () { newImg.style.opacity = '1'; };
if (newImg.complete) newImg.style.opacity = '1';
}
}, 150);
thumbs.forEach(function (t) { t.classList.remove('active'); });
thumb.classList.add('active');
});
});
});
}
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', initSwitcher);
} else {
initSwitcher();
}
if (window.mw) {
mw.hook('wikipage.content').add(initSwitcher);
}
})(); </script>