微件

TierListMaker:修订间差异

来自卡厄思梦境WIKI

律Rhyme留言 | 贡献
创建页面,内容为“ <includeonly> <style> .avatar-frame { position: relative; display: inline-block; vertical-align: top; border: 3px solid #ccc; border-radius: 5px; overflow: hidden; box-shadow: 0 2px 5px rgba(0,0,0,0.1); background: #f5f5f5; transition: transform 0.3s ease, box-shadow 0.3s ease; cursor: grab; margin: 2px; } .avatar-frame:active { cursor: grabbing; } .avatar-frame.dragging { opacity: 0.5; transform: scal…”
 
律Rhyme留言 | 贡献
无编辑摘要
 
(未显示同一用户的22个中间版本)
第1行: 第1行:
<includeonly>
<includeonly>
<style>
<style>
.avatar-frame {
.tierlist-controls {
    position: relative;
  display: flex;
    display: inline-block;
  gap: 8px;
    vertical-align: top;
  margin: 8px 0 12px 0;
    border: 3px solid #ccc;
}
    border-radius: 5px;
.btn {
    overflow: hidden;
  display: inline-block;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);  
  padding: 6px 12px;
    background: #f5f5f5;
  background: #f0f0f0;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
  border: 1px solid #ccc;
    cursor: grab;
  color: #333;
    margin: 2px;
  border-radius: 4px;
  cursor: pointer;
  user-select: none;
}
}
 
.btn:hover { background: #e6e6e6; }
.avatar-frame:active {
.btn.primary { background: #4a8cf6; color: #fff; border-color: #3b78de; }
    cursor: grabbing;
.btn.primary:hover { background: #3b78de; }
.tierlist-table {
  width: 100%;
  table-layout: fixed;
}
}
 
.tier-row .tier-head {
.avatar-frame.dragging {
  position: relative;
    opacity: 0.5;
  width: 120px;
    transform: scale(1.05);
  color: #fff;
  text-align: center;
  font-size: 18px;
  font-weight: bold;
  padding: 8px;
  white-space: nowrap;
  border: 1px solid #ccc;
  background: #555;
}
}
 
.tier-row .tier-cell {
.avatar-frame:hover {
  border: 1px solid #ccc;
    transform: scale(1.05);
  padding: 0px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    z-index: 10;
}
}
 
.tier-tools {
.avatar-frame img {
  position: absolute;
    display: block;
  right: 6px;
    width: 100px;
  top: 6px;
    height: 100px;
  display: flex;
    object-fit: cover;
  gap: 6px;
    pointer-events: none;
}
}
 
/* 导出时隐藏工具按钮 */
.avatar-name {
.exporting .tier-tools {
    position: absolute;
  display: none !important;
    left: 0;
    bottom: 0;
    padding: 2px 8px;
    color: white;
    font-size: 12px;
    font-weight: bold;
    text-shadow: 0 0 2px black, 0 0 2px black;
    white-space: nowrap;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    border-top-right-radius: 3px;
    pointer-events: none;
}
}
 
.color-toggle {
.tier-row {
  width: 18px;
    position: relative;
  height: 18px;
    background-color: #fafafa;
  border-radius: 3px;
    border: 2px dashed transparent;
  border: 1px solid rgba(0,0,0,0.2);
    transition: all 0.2s ease;
  cursor: pointer;
  background: rgba(255,255,255,0.6);
}
}
 
.delete-row {
.tier-row.drag-over {
  font-size: 12px;
    background-color: #e3f2fd;
  padding: 2px 6px;
    border-color: #2196F3;
  border-radius: 3px;
  background: rgba(0,0,0,0.1);
  cursor: pointer;
}
}
 
.delete-row:hover { background: rgba(0,0,0,0.2); }
#character-pool {
.tier-dropzone {
    position: relative;
  min-height: 112px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: flex-start;
  padding: 4px;
}
}
 
.tier-dropzone.pool {
#character-pool.drag-over {
  border: 2px dashed #ccc;
    background-color: #fff3e0;
  padding: 8px;
  border-radius: 6px;
  background: #fafafa;
}
}
 
/* 导出时隐藏角色池 */
.tierlist-table {
.exporting .pool-wrapper {
    width: 100%;
  display: none !important;
    table-layout: fixed;
}
}
 
.pool-wrapper { margin-top: 12px; }
.tierlist-table th {
.pool-header {
    width: 100px;
  font-weight: bold;
  margin-bottom: 6px;
}
}
 
.avatar-frame {
.tierlist-btn {
  position: relative;
    padding: 10px 20px;
  display: inline-block;
    font-size: 16px;
  vertical-align: top;
    color: white;
  border: 3px solid #ccc;
    border: none;
  border-radius: 5px;
    border-radius: 5px;
  overflow: hidden;
    cursor: pointer;
  box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    margin-right: 10px;
  background: #f5f5f5;
    transition: all 0.2s ease;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  cursor: move;
}
}
 
.avatar-frame.dragging {
.tierlist-btn-save {
  opacity: 0.7;
    background-color: #4CAF50;
  transform: scale(1.03);
  border-color: #4a8cf6;
  z-index: 10;
}
}
 
.avatar-frame img {
.tierlist-btn-save:hover {
  display: block;
    background-color: #45a049;
  width: 100px;
  height: 100px;
  object-fit: cover;
  pointer-events: none;
  -webkit-user-drag: none;
}
}
 
.avatar-name {
.tierlist-btn-reset {
  position: absolute;
    background-color: #f44336;
  left: 0;
  bottom: 0;
  padding: 2px 8px;
  color: white;
  font-size: 12px;
  font-weight: bold;
  text-shadow: 0 0 2px black, 0 0 2px black;
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  border-top-right-radius: 3px;
}
}
 
.color-palette {
.tierlist-btn-reset:hover {
  position: absolute;
    background-color: #da190b;
  display: none;
  gap: 6px;
  flex-wrap: wrap;
  width: 210px;
  padding: 8px;
  background: #fff;
  border: 1px solid #ccc;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  border-radius: 6px;
  z-index: 9999;
}
}
 
.color-swatch {
.tierlist-btn:active {
  width: 24px; height: 24px;
    transform: scale(0.98);
  border-radius: 4px;
  border: 1px solid rgba(0,0,0,0.2);
  cursor: pointer;
}
}
 
.color-swatch:hover { outline: 2px solid rgba(0,0,0,0.2); }
.character-pool-container {
.tier-label {
    background-color: #f9f9f9;
  display: inline-block;
    padding: 15px;
  padding: 2px 6px;
    border: 2px dashed #ccc;
  border-radius: 3px;
    border-radius: 5px;
  background: rgba(255,255,255,0.15);
    margin-top: 20px;
}
}
 
.tier-label[contenteditable="true"] {
.character-pool-container h3 {
  outline: none;
    margin-top: 0;
  cursor: text;
    color: #333;
}
}
</style>
</style>
<script src="https://cdnjs.cloudflare.com/ajax/libs/html2canvas/1.4.1/html2canvas.min.js"></script>


<script>
<script>
(function() {
(function() {
     'use strict';
  function ready(fn) {
     if (document.readyState !== 'loading') fn();
    else document.addEventListener('DOMContentLoaded', fn);
  }
  function contrastColor(hex) {
    hex = (hex || '').replace('#','');
    if (hex.length === 3) hex = hex.split('').map(c => c + c).join('');
    if (!/^[0-9a-fA-F]{6}$/.test(hex)) return '#fff';
    var r = parseInt(hex.substr(0,2), 16);
    var g = parseInt(hex.substr(2,2), 16);
    var b = parseInt(hex.substr(4,2), 16);
    var yiq = ((r*299)+(g*587)+(b*114))/1000;
    return yiq >= 128 ? '#000' : '#fff';
  }
  function getDragAfterElement(container, y) {
    const elements = [...container.querySelectorAll('.avatar-frame:not(.dragging)')];
    return elements.reduce((closest, child) => {
      const box = child.getBoundingClientRect();
      const offset = y - box.top - box.height/2;
      if (offset < 0 && offset > closest.offset) {
        return { offset: offset, element: child };
      } else {
        return closest;
      }
    }, { offset: Number.NEGATIVE_INFINITY, element: null }).element;
  }
  function ensureCrossOrigin(img) {
    try {
      if (!img) return;
      if (!img.crossOrigin) img.crossOrigin = 'anonymous';
      if (!img.referrerPolicy) img.referrerPolicy = 'no-referrer';
    } catch(e) {}
  }
  function makeDraggable(avatar) {
    if (!avatar || avatar._draggableInit) return;
    avatar._draggableInit = true;
    avatar.setAttribute('draggable', 'true');
    avatar.classList.add('draggable-avatar');
    avatar.querySelectorAll('img').forEach(ensureCrossOrigin);
 
    avatar.addEventListener('dragstart', function(e) {
      avatar.classList.add('dragging');
      avatar._prevParent = avatar.parentNode;
      e.dataTransfer.setData('text/plain', avatar.dataset.id || avatar.querySelector('.avatar-name')?.textContent || '');
      e.dataTransfer.effectAllowed = 'move';
    });
    avatar.addEventListener('dragend', function() {
      avatar.classList.remove('dragging');
      cleanupEmptyWrapper(avatar._prevParent);
      avatar._prevParent = null;
    });
  }
  function initAvatars(root) {
    if (!root) return;
    const avatars = root.querySelectorAll('.avatar-frame');
    avatars.forEach(function(av) {
      if (!av.dataset.id) {
        const nameEl = av.querySelector('.avatar-name');
        av.dataset.name = nameEl ? nameEl.textContent.trim() : '';
      }
      makeDraggable(av);
    });
  }
  function cleanupEmptyWrapper(node) {
    if (!node || node.nodeType !== 1) return;
    if (node.classList && node.classList.contains('tier-dropzone')) return;
    const hasElementChild = node.querySelector('.avatar-frame');
    const onlyWhitespace = !node.textContent || node.textContent.trim().length === 0;
    if (!hasElementChild && node.childElementCount === 0 && onlyWhitespace) {
      node.parentNode && node.parentNode.removeChild(node);
    }
  }
  function cleanupEmptyPlaceholdersIn(container) {
    if (!container) return;
    Array.from(container.children).forEach(function(child) {
      if (child.nodeType !== 1) return;
      if (child.classList.contains('avatar-frame')) return;
      const hasAvatarInside = !!child.querySelector('.avatar-frame');
      const onlyWhitespace = !child.textContent || child.textContent.trim().length === 0;
      if (!hasAvatarInside && child.childElementCount === 0 && onlyWhitespace) {
        child.remove();
      }
    });
  }
  function initDropzone(zone) {
    if (!zone || zone._dropzoneInit) return;
    zone._dropzoneInit = true;
 
    zone.addEventListener('dragover', function(e) {
      e.preventDefault();
      e.dataTransfer.dropEffect = 'move';
      const afterElement = getDragAfterElement(zone, e.clientY);
      const dragging = document.querySelector('.avatar-frame.dragging');
      if (!dragging) return;
      if (afterElement == null) {
        if (dragging.parentNode !== zone) zone.appendChild(dragging);
      } else {
        if (afterElement !== dragging) zone.insertBefore(dragging, afterElement);
      }
    });
 
    zone.addEventListener('drop', function(e) {
      e.preventDefault();
      e.stopPropagation();
      const dragging = document.querySelector('.avatar-frame.dragging');
      if (dragging) {
        if (dragging.parentNode !== zone) zone.appendChild(dragging);
        cleanupEmptyWrapper(dragging._prevParent);
        dragging._prevParent = null;
      }
      if (zone.classList.contains('pool')) {
        cleanupEmptyPlaceholdersIn(zone);
      }
    });
  }
  function buildEditableHead(th) {
    const currentText = (th.childNodes[0] && th.childNodes[0].nodeType === 3)
      ? th.childNodes[0].nodeValue.trim()
      : th.textContent.trim();
    const tools = th.querySelector('.tier-tools');
    th.innerHTML = '';
    const label = document.createElement('div');
    label.className = 'tier-label';
    label.setAttribute('contenteditable', 'true');
    label.textContent = currentText || '未命名';
    const toolsWrap = tools || (function() {
      const t = document.createElement('div');
      t.className = 'tier-tools';
      const color = document.createElement('div');
      color.className = 'color-toggle';
      color.title = '更改颜色';
      const del = document.createElement('div');
      del.className = 'delete-row';
      del.textContent = '删除';
      del.title = '删除该行';
      t.appendChild(color); t.appendChild(del);
      return t;
    })();
    th.appendChild(label);
    th.appendChild(toolsWrap);
    const initialBg = th.getAttribute('data-initial-bg') || '#555';
    th.style.background = initialBg;
    th.style.color = contrastColor(initialBg);
    attachColorPalette(toolsWrap.querySelector('.color-toggle'), th);
    const delBtn = toolsWrap.querySelector('.delete-row');
    delBtn.addEventListener('click', function() {
      const tr = th.closest('tr');
      const dropzone = tr.querySelector('.tier-dropzone');
      const pool = document.getElementById('character-pool');
      Array.from(dropzone.querySelectorAll('.avatar-frame')).forEach(function(av) {
        pool.appendChild(av);
      });
      tr.parentNode.removeChild(tr);
    });
  }
  function attachColorPalette(toggle, th) {
    if (!toggle) return;
    const palette = document.createElement('div');
    palette.className = 'color-palette';
    const colors = [
      '#e53935','#d81b60','#8e24aa','#5e35b1','#3949ab','#1e88e5','#039be5','#00acc1',
      '#00897b','#43a047','#7cb342','#c0ca33','#fdd835','#fb8c00','#f4511e','#6d4c41',
      '#546e7a','#9e9e9e','#000000','#ffffff'
    ];
    colors.forEach(function(c) {
      const sw = document.createElement('div');
      sw.className = 'color-swatch';
      sw.style.background = c;
      sw.addEventListener('click', function() {
        th.style.background = c;
        th.style.color = contrastColor(c);
        palette.style.display = 'none';
      });
      palette.appendChild(sw);
    });
    document.body.appendChild(palette);
    function placePalette() {
      const rect = toggle.getBoundingClientRect();
      palette.style.left = (window.scrollX + rect.left) + 'px';
      palette.style.top  = (window.scrollY + rect.bottom + 6) + 'px';
    }
    toggle.addEventListener('click', function(e) {
      e.stopPropagation();
      if (palette.style.display === 'block') {
        palette.style.display = 'none';
      } else {
        placePalette();
        palette.style.display = 'block';
      }
    });
    document.addEventListener('click', function(e) {
      if (e.target === toggle || palette.contains(e.target)) return;
      palette.style.display = 'none';
    });
    window.addEventListener('scroll', function() {
      if (palette.style.display === 'block') placePalette();
    });
    window.addEventListener('resize', function() {
      if (palette.style.display === 'block') placePalette();
    });
  }
  function addNewRow() {
    const tbody = document.querySelector('#tierlist-table tbody') || document.querySelector('#tierlist-table');
    const tr = document.createElement('tr');
    tr.className = 'tier-row';
    const th = document.createElement('th');
    th.className = 'tier-head';
    th.setAttribute('data-initial-bg', '#8888ff');
    th.textContent = '新行';
    const td = document.createElement('td');
    td.className = 'tier-cell';
    const dz = document.createElement('div');
    dz.className = 'tier-dropzone';
    dz.setAttribute('data-tier', 'CUSTOM');
    td.appendChild(dz);
    tr.appendChild(th);
    tr.appendChild(td);
    tbody.appendChild(tr);
    initDropzone(dz);
    buildEditableHead(th);
  }
  function ensureHtml2Canvas(cb) {
    if (window.html2canvas) { cb(); return; }
    var s = document.createElement('script');
    s.src = 'https://cdn.jsdelivr.net/npm/html2canvas@1.4.1/dist/html2canvas.min.js';
    s.onload = cb;
    s.onerror = function() {
      alert('加载截图库失败,请检查网络或跨域策略。');
    };
    document.body.appendChild(s);
  }
  function downloadCanvas(canvas) {
    function done(blobOrUrl) {
      try {
        const link = document.createElement('a');
        const isBlob = blobOrUrl instanceof Blob;
        const url = isBlob ? (URL.createObjectURL(blobOrUrl)) : blobOrUrl;
        link.href = url;
        link.download = 'tierlist.png';
        document.body.appendChild(link);
        link.click();
        document.body.removeChild(link);
        if (isBlob) setTimeout(() => URL.revokeObjectURL(url), 0);
      } catch (e) {
        const dataUrl = canvas.toDataURL('image/png');
        window.open(dataUrl, '_blank');
      }
    }
    if (canvas.toBlob) {
      canvas.toBlob(function(blob) {
        if (blob) done(blob);
        else done(canvas.toDataURL('image/png'));
      }, 'image/png');
    } else {
      done(canvas.toDataURL('image/png'));
    }
  }
  function prepareImagesForExport(container) {
    if (!container) return;
    container.querySelectorAll('img').forEach(ensureCrossOrigin);
  }
  function savePNG() {
    const maker = document.getElementById('tierlist-maker');
    const table = document.getElementById('tierlist-table');
    if (!table) {
      alert('未找到要导出的表格。');
      return;
    }
      
      
     // 防止重复初始化
     // 添加导出样式类
     if (window.TierlistMaker) {
     maker.classList.add('exporting');
        console.log('TierlistMaker already initialized');
    prepareImagesForExport(table);
        return;
    }
      
      
     const TierlistMaker = {
     ensureHtml2Canvas(function() {
        draggedElement: null,
      // 稍微延迟以确保CSS生效
        sourceContainer: null,
      setTimeout(function() {
        initialized: false,
        html2canvas(table, {
       
          backgroundColor: '#ffffff',
        init: function() {
          scale: 2,
            if (this.initialized) return;
          useCORS: true,
           
          allowTaint: false,
            // 等待DOM完全加载
          imageTimeout: 15000
            if (document.readyState === 'loading') {
         }).then(function(canvas) {
                document.addEventListener('DOMContentLoaded', () => this.setup());
          downloadCanvas(canvas);
            } else {
         }).catch(function(err) {
                this.setup();
          console.error('html2canvas 失败', err);
            }
          alert('保存PNG失败:' + (err && err.message ? err.message : '未知错误'));
           
        }).finally(function() {
            this.initialized = true;
          maker.classList.remove('exporting');
        },
        });
       
      }, 100);
         setup: function() {
    });
            this.initDragAndDrop();
  }
            this.initButtons();
  function resetAll() {
         },
    const pool = document.getElementById('character-pool');
       
    if (!pool) return;
        initDragAndDrop: function() {
    const rows = document.querySelectorAll('#tierlist-table .tier-dropzone');
            const avatars = document.querySelectorAll('.avatar-frame');
    rows.forEach(function(zone) {
           
      if (zone.classList.contains('pool')) return;
            avatars.forEach(avatar => {
      Array.from(zone.querySelectorAll('.avatar-frame')).forEach(function(av) {
                // 移除旧的事件监听器
        pool.appendChild(av);
                const newAvatar = avatar.cloneNode(true);
      });
                avatar.parentNode.replaceChild(newAvatar, avatar);
      cleanupEmptyPlaceholdersIn(zone);
               
    });
                newAvatar.setAttribute('draggable', 'true');
    cleanupEmptyPlaceholdersIn(pool);
                newAvatar.addEventListener('dragstart', (e) => this.handleDragStart(e, newAvatar));
  }
                newAvatar.addEventListener('dragend', (e) => this.handleDragEnd(e, newAvatar));
 
            });
  ready(function() {
           
    document.querySelectorAll('#tierlist-table .tier-head').forEach(buildEditableHead);
            // 为tier行添加拖放事件
    document.querySelectorAll('.tier-dropzone').forEach(initDropzone);
            const tierRows = document.querySelectorAll('.tier-row');
    initAvatars(document.getElementById('character-pool'));
            tierRows.forEach(row => {
 
                row.addEventListener('dragover', (e) => this.handleDragOver(e, row));
    var addBtn = document.getElementById('add-row');
                row.addEventListener('drop', (e) => this.handleDrop(e, row));
    if (addBtn) addBtn.addEventListener('click', addNewRow);
                row.addEventListener('dragleave', (e) => this.handleDragLeave(e, row));
    var saveBtn = document.getElementById('save-png');
            });
    if (saveBtn) saveBtn.addEventListener('click', savePNG);
           
 
            // 为角色池添加拖放事件
    (function insertResetButton() {
            const characterPool = document.getElementById('character-pool');
      const controls = document.querySelector('#tierlist-maker .tierlist-controls');
            if (characterPool) {
      if (!controls || document.getElementById('reset-roles')) return;
                characterPool.addEventListener('dragover', (e) => this.handleDragOver(e, characterPool));
      const resetBtn = document.createElement('div');
                characterPool.addEventListener('drop', (e) => this.handleDrop(e, characterPool));
      resetBtn.id = 'reset-roles';
                characterPool.addEventListener('dragleave', (e) => this.handleDragLeave(e, characterPool));
      resetBtn.className = 'btn';
            }
      resetBtn.textContent = '重置';
        },
      controls.insertBefore(resetBtn, controls.querySelector('#save-png') || null);
       
      resetBtn.addEventListener('click', resetAll);
        handleDragStart: function(e, element) {
    })();
            this.draggedElement = element;
 
            this.sourceContainer = element.parentElement;
    const pool = document.getElementById('character-pool');
            element.classList.add('dragging');
    if (pool) {
            e.dataTransfer.effectAllowed = 'move';
      const obs = new MutationObserver(function(muts) {
            e.dataTransfer.setData('text/html', element.innerHTML);
        muts.forEach(function(m) {
        },
          if (m.addedNodes && m.addedNodes.length) {
       
            m.addedNodes.forEach(function(n) {
        handleDragEnd: function(e, element) {
              if (n.nodeType === 1) {
            element.classList.remove('dragging');
                 if (n.classList.contains('avatar-frame')) {
           
                  makeDraggable(n);
            // 移除所有drag-over类
            document.querySelectorAll('.drag-over').forEach(el => {
                el.classList.remove('drag-over');
            });
        },
       
        handleDragOver: function(e, element) {
            if (e.preventDefault) {
                e.preventDefault();
            }
           
            e.dataTransfer.dropEffect = 'move';
            element.classList.add('drag-over');
           
            return false;
        },
       
        handleDragLeave: function(e, element) {
            element.classList.remove('drag-over');
        },
       
        handleDrop: function(e, element) {
            if (e.stopPropagation) {
                e.stopPropagation();
            }
           
            e.preventDefault();
            element.classList.remove('drag-over');
           
            if (this.draggedElement && this.draggedElement !== element) {
                // 移动元素到新位置
                element.appendChild(this.draggedElement);
               
                // 重新初始化拖拽
                this.initDragAndDrop();
            }
           
            return false;
        },
       
        initButtons: function() {
            const saveBtn = document.getElementById('save-tierlist');
            const resetBtn = document.getElementById('reset-tierlist');
           
            if (saveBtn) {
                saveBtn.addEventListener('click', () => this.saveTierlist());
            }
           
            if (resetBtn) {
                resetBtn.addEventListener('click', () => this.resetTierlist());
            }
        },
       
        saveTierlist: function() {
            const table = document.getElementById('tierlist-table');
            if (!table) {
                alert('未找到 Tierlist 表格!');
                return;
            }
           
            // 检查 html2canvas 是否加载
            if (typeof html2canvas === 'undefined') {
                alert('正在加载图片生成库,请稍后再试...');
                return;
            }
           
            // 临时隐藏角色池和按钮
            const poolContainer = document.querySelector('.character-pool-container');
            const originalDisplay = poolContainer ? poolContainer.style.display : '';
           
            if (poolContainer) {
                poolContainer.style.display = 'none';
            }
           
            html2canvas(table, {
                scale: 2,
                backgroundColor: '#ffffff',
                logging: false,
                useCORS: true,
                allowTaint: true
            }).then(canvas => {
                // 恢复显示
                if (poolContainer) {
                    poolContainer.style.display = originalDisplay;
                }
               
                // 下载图片
                const link = document.createElement('a');
                const timestamp = new Date().toISOString().replace(/[:.]/g, '-').slice(0, -5);
                link.download = 'tierlist_' + timestamp + '.png';
                link.href = canvas.toDataURL('image/png');
                link.click();
            }).catch(err => {
                 console.error('生成图片失败:', err);
                if (poolContainer) {
                    poolContainer.style.display = originalDisplay;
                 }
                 }
                 alert('生成图片失败,请查看控制台了解详情');
                 n.querySelectorAll && n.querySelectorAll('.avatar-frame').forEach(makeDraggable);
                if (pool.contains(n)) cleanupEmptyPlaceholdersIn(pool);
              }
             });
             });
        },
          }
       
         });
         resetTierlist: function() {
      });
            if (!confirm('确定要重置所有排列吗?此操作不可撤销。')) {
      obs.observe(pool, { childList: true, subtree: true });
                return;
    }
            }
  });
           
            const pool = document.getElementById('character-pool');
            if (!pool) {
                alert('未找到角色池!');
                return;
            }
           
            const allAvatars = document.querySelectorAll('.avatar-frame');
           
            // 清空所有tier行
            document.querySelectorAll('.tier-row').forEach(row => {
                row.innerHTML = '';
            });
           
            // 将所有头像移回角色池
            allAvatars.forEach(avatar => {
                pool.appendChild(avatar);
            });
           
            // 重新初始化
            this.initDragAndDrop();
        }
    };
   
    // 暴露到全局
    window.TierlistMaker = TierlistMaker;
   
    // 自动初始化
    TierlistMaker.init();
})();
})();
</script>
</script>
</includeonly>
</includeonly>

2025年10月29日 (三) 14:50的最新版本