-

本WIKI编辑权限开放,欢迎收藏起来防止迷路,也希望有爱的小伙伴和我们一起编辑哟~ 编辑帮助:目录BWIKI反馈留言板


请选择语言:

版本250722.2
全站通知:

Widget:沙盒1212

来自赛尔号WIKI_BWIKI_哔哩哔哩
跳到导航 跳到搜索

<!DOCTYPE html> <html lang="zh-CN"> <head>

   <meta charset="UTF-8">
   <title>XML 提取 & 页面创建</title>
   <style>
       body { font-family: Arial, sans-serif; margin: 20px; }
       textarea { width: 100%; height: 120px; font-family: monospace; }
       button { margin-top: 10px; padding: 8px 16px; }
       .log { margin-top: 20px; white-space: pre-wrap; font-size: 14px; }
   </style>

</head> <body>

粘贴 XML(可多条)

   <textarea id="xmlInput" placeholder="<Effect id="22" argsNum="2" info="..." param="..."/>"></textarea>
   
<button onclick="handleXML()">解析并创建页面</button>
   <script>
       const api = 'https://wiki.biligame.com/seer/api.php';
       function log(msg) {
           document.getElementById('log').textContent += msg + '\n';
       }
       function getToken() {
           return fetch(`${api}?action=query&meta=tokens&format=json`, { credentials: 'include' })
               .then(r => r.json())
               .then(j => j.query.tokens.csrftoken);
       }
       function createPage(title, text, token) {
           const fd = new FormData();
           fd.append('action', 'edit');
           fd.append('title', title);
           fd.append('text', text);
           fd.append('token', token);
           fd.append('format', 'json');
           return fetch(api, { method: 'POST', credentials: 'include', body: fd })
               .then(r => r.json())
               .then(j => {
                   if (j.edit && j.edit.result === 'Success') {
                       log(`✅ 已创建:${title}`);
                   } else {
                       log(`❌ 创建失败:${title} ` + JSON.stringify(j));
                   }
               });
       }
       async function handleXML() {
           const xmlText = document.getElementById('xmlInput').value.trim();
           if (!xmlText) return log('请输入 XML');
           log('开始处理...\n');
           const token = await getToken();
           const lines = xmlText.split(/[\r\n]+/);
           for (let line of lines) {
               line = line.trim();
               if (!line) continue;
               const m = line.match(/<Effect\s+([^>]+)\/>?/);
               if (!m) { log(`跳过无效行:${line}`); continue; }
               const attr = {};
               m[1].replace(/(\w+)="([^"]*)"/g, (_, k, v) => attr[k] = v);
               const { id, argsNum, info, param } = attr;
               const title = `效果:${id}`;
               const text = `

[[分类:${id]]

[[效果:${id|${id]] 参数个数:${argsNum 类型:${param
技能效果描述:
${info
拥有此效果的技能(最多只显示前1000个技能):
技能ID 技能名称 技能效果

}`;

               await createPage(title, text, token);
           }
           log('\n全部完成。');
       }
   </script>

</body> </html>