|
|
| 第1行: |
第1行: |
| /**
| | mw.loader.load('https://cdn.jsdelivr.net/npm/wikiplus-core@latest/dist/Main.js'); |
| * -------------------------------------------------------------------------
| | mw.loader.load('https://testingcf.jsdelivr.net/npm/wikiplus-highlight@latest'); |
| * !!! DON'T MODIFY THIS PAGE MANUALLY, YOUR CHANGES WILL BE OVERWRITTEN !!!
| |
| * -------------------------------------------------------------------------
| |
| */
| |
| var _addText = '{{GHIACode|page=GHIA:MoegirlPediaInterfaceCodes/blob/master/src/gadgets/Wikiplus/Gadget-Wikiplus.js|user=[[U:AnnAngela]]|co-authors=GH:github-actions[bot]|longId=103d1a563ea4ccc8ff29fb55c9bcd88329a56eb5|shortId=103d1a56|summary=feat: rename (#594)|body=<nowiki>Co-authored-by: github-actions[bot] <41898282+github-actions[bot]📧users.noreply.github.com></nowiki>}}';
| |
| | |
| /* <pre> */
| |
| | |
| "use strict";
| |
| (async () => {
| |
| // 加载核心代码(依赖缓存工具,兼容原有逻辑)
| |
| await libCachedCode.injectCachedCode("https://npm.elemecdn.com/wikiplus-core@latest", "script");
| |
|
| |
| // 休眠函数(保持不变)
| |
| const sleep = t => new Promise(e => setTimeout(e, t));
| |
|
| |
| // 兼容更多编辑按钮选择器
| |
| const editBtnSelectors = "#ca-edit, #edit-button, .mw-editbutton";
| |
| if (!document.querySelector(editBtnSelectors)) return;
| |
|
| |
| // 等待 Wikiplus 原始按钮加载
| |
| let wikiplusTopBtn = document.querySelector("#Wikiplus-Edit-TopBtn");
| |
| for (; !wikiplusTopBtn;) {
| |
| await sleep(100);
| |
| wikiplusTopBtn = document.querySelector("#Wikiplus-Edit-TopBtn");
| |
| }
| |
|
| |
| // 创建快速编辑按钮
| |
| const wplusBtn = document.createElement("a");
| |
| wplusBtn.id = "ca-wikiplus";
| |
| wplusBtn.innerHTML = '<span style="align-self:center;font:0.7em bold;">W+</span>';
| |
| wplusBtn.title = "快速编辑";
| |
| wplusBtn.addEventListener("click", () => wikiplusTopBtn.click());
| |
|
| |
| // 等待页面结构就绪后插入按钮(兼容动态生成的工具条)
| |
| mw.hook("wikipage.content").add(() => {
| |
| const editBtn = document.querySelector(editBtnSelectors);
| |
| if (editBtn && editBtn.parentNode) {
| |
| // 继承编辑按钮样式类,确保视觉一致
| |
| wplusBtn.className = editBtn.className;
| |
| // 插入到编辑按钮后面
| |
| editBtn.parentNode.insertBefore(wplusBtn, editBtn.nextSibling);
| |
| }
| |
| });
| |
| })();
| |
| | |
| /* </pre> */
| |
mw.loader.load('https://cdn.jsdelivr.net/npm/wikiplus-core@latest/dist/Main.js');
mw.loader.load('https://testingcf.jsdelivr.net/npm/wikiplus-highlight@latest');