打开/关闭菜单
打开/关闭外观设置菜单
打开/关闭个人菜单
未登录
未登录用户的IP地址会在进行任意编辑后公开展示。

微件:GF立绘切换

来自OGAS数据中枢
弃权者留言 | 贡献2026年5月15日 (五) 21:45的版本

<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>