MediaWiki:Gadget-rollback-summary.js:修订间差异
外观
AnnAngela-dbot(留言 | 贡献) 代码变动:103d1a56 - feat: rename (#594) by U:AnnAngela, co-authored-by: GH:github-actions[bot] 标签:由机器人或全自动脚本执行的操作 |
AnnAngela-dbot(留言 | 贡献) 标签:由机器人或全自动脚本执行的操作 疑似外链调用内部文件 |
||
| 第4行: | 第4行: | ||
* ------------------------------------------------------------------------- | * ------------------------------------------------------------------------- | ||
*/ | */ | ||
var _addText = '{{GHIACode|page=GHIA:MoegirlPediaInterfaceCodes/blob/master/src/gadgets/rollback-summary/Gadget-rollback-summary.js|user=[[U: | var _addText = '{{GHIACode|page=GHIA:MoegirlPediaInterfaceCodes/blob/master/src/gadgets/rollback-summary/Gadget-rollback-summary.js|user=[[U:SaoMikoto]]|co-authors=|longId=ec464ab72ec9b83c039321730bd3630a9edbcbae|shortId=ec464ab7|summary=fix(Gadget/rollback-summary): 防止最近更改发生变动后不加载 (#750)|body=<nowiki>* fix(Gadget/rollback-summary): 防止最近更改发生变动后不加载↩↩* fix(Gadget/rollback-summary): 改用.mw-changeslist并防止反复触发↩↩* fix(Gadget/rollback-summary): 取消按钮意外触发</nowiki>}}'; | ||
/* <pre> */ | /* <pre> */ | ||
"use strict";$(()=>{const o=mw.config.get("wgUserGroups",[]);if(!o.includes("sysop")&&!o.includes("patroller"))return;mw.config.set({wgRollbacking:!1,wgRollbackTool:"inited"});const | "use strict";$(()=>{const o=mw.config.get("wgUserGroups",[]);if(!o.includes("sysop")&&!o.includes("patroller"))return;mw.config.set({wgRollbacking:!1,wgRollbackTool:"inited"});const n={alreadyrolled:wgULS("已被回退","已被還原"),onlyauthor:wgULS("该页面只有一位编辑者参与编辑,无法回退","該頁面只有一位編輯者參與編輯,無法還原"),missingparams:wgULS('必须要有参数"title"或参数"pageid"之一','必須存在參數"title"或參數"pageid"之一'),notitle:wgULS('参数"title"必须被设置','參數"title"必須被設置'),notoken:wgULS('参数"token"必须被设置','參數"token"必須被設置'),nouser:wgULS('参数"user"必须被设置','參數"user"必須被設置')},loop=(o,n)=>{const e=$(n);e.data("href")||(e.data("href",e.attr("href")).removeAttr("href").attr("title",`${n.title}(启用自定义摘要)`).css("cursor","pointer").append("<sup>+</sup>").find("sup").on("click",o=>o.stopPropagation()),$(".ns-special")[0]&&e.text().includes("10")&&e.parent().text(wgULS("[超过10次的编辑]","[超過10次的編輯]")).attr("title","超过10次的编辑请使用撤销功能,以便检查差异(自定义摘要小工具)"),n.onmouseover=$.noop,n.onmouseout=$.noop,n.onmousedown=$.noop)};$(".mw-rollback-link a").each(loop);const e=new mw.Api;$(document.body).on("click",async o=>{const t=o.target;if(!$(t).is(".mw-rollback-link a")||$(t).closest(".jquery-confirmable-button-no")[0])return!0;const l=$(t),i=l.parent();if(l.data("href")||loop(0,t),!i.find(l)[0])return!1;if(mw.config.get("wgRollbacking"))return!1;const r=await oouiDialog.prompt(`<ul><li>${wgULS("回退操作的编辑摘要","還原操作的編輯摘要")}:<code>xxx//Rollback</code></li><li>${wgULS("空白则使用默认回退摘要","留空則使用默認的還原摘要")},${wgULS("取消则不进行回退","取消則不進行還原")}</li></ul><hr>${wgULS("请输入回退摘要","請輸入還原摘要")}:`,{title:"回退小工具",size:"medium",required:!1});if(null!==r){const o=new mw.Uri(l.data("href"));l.replaceWith(`<span id="rbing"><img src="https://img.moegirl.org.cn/common/d/d1/Windows_10_loading.gif" style="height: 1em; margin-top: -.25em;">${wgULS("正在回退中","正在還原")}……</span>`);const t=$("#rbing");$(".mw-rollback-link a").not(t).css({color:"#aaa","text-decoration":"none"}),mw.config.set("wgRollbacking",!0);const i=r?`${r} //Rollback`:"//Rollback";if(o.query.from)try{await e.post({action:"rollback",assertuser:mw.config.get("wgUserName"),title:o.query.title,user:o.query.from,summary:i,token:o.query.token,format:"json"}),t.css("color","green").html(`成功!${wgULS("将在","將在")}<span id="rbcount">3</span>秒${wgULS("内刷新","內重新整理")}`)}catch(o){const e=o instanceof Error?`${o} ${o.stack.split("\n")[1].trim()}`:$.isPlainObject(o)?JSON.stringify(o):"string"==typeof o&&Reflect.has(n,o)?n[o]:`${o}`;t.css("color","red").html(`${wgULS("错误","錯誤")}:${e}。${wgULS("将在","將在")}<span id="rbcount">3</span>${wgULS("秒内刷新","秒內重新整理")}`)}finally{(()=>{const o=$("#rbcount");let n=3;setInterval(()=>{0===--n&&window.location.reload(),o.text(n>0?n:"0")},1e3)})()}else o.query.summary=i,window.open(o.toString(),"_self")}return!1}),(new Image).src="https://img.moegirl.org.cn/common/d/d1/Windows_10_loading.gif";const t=document.querySelector(".mw-changeslist");t&&new MutationObserver(o=>{o.forEach(o=>{o.addedNodes.forEach(o=>{1===o.nodeType&&$(o).find(".mw-rollback-link a:not([data-href])").addBack(".mw-rollback-link a:not([data-href])").each(loop)})})}).observe(t,{childList:!0})}); | ||
/* </pre> */ | /* </pre> */ | ||
2025年11月19日 (三) 14:26的最新版本
/**
* -------------------------------------------------------------------------
* !!! DON'T MODIFY THIS PAGE MANUALLY, YOUR CHANGES WILL BE OVERWRITTEN !!!
* -------------------------------------------------------------------------
*/
var _addText = '{{GHIACode|page=GHIA:MoegirlPediaInterfaceCodes/blob/master/src/gadgets/rollback-summary/Gadget-rollback-summary.js|user=[[U:SaoMikoto]]|co-authors=|longId=ec464ab72ec9b83c039321730bd3630a9edbcbae|shortId=ec464ab7|summary=fix(Gadget/rollback-summary): 防止最近更改发生变动后不加载 (#750)|body=<nowiki>* fix(Gadget/rollback-summary): 防止最近更改发生变动后不加载↩↩* fix(Gadget/rollback-summary): 改用.mw-changeslist并防止反复触发↩↩* fix(Gadget/rollback-summary): 取消按钮意外触发</nowiki>}}';
/* <pre> */
"use strict";$(()=>{const o=mw.config.get("wgUserGroups",[]);if(!o.includes("sysop")&&!o.includes("patroller"))return;mw.config.set({wgRollbacking:!1,wgRollbackTool:"inited"});const n={alreadyrolled:wgULS("已被回退","已被還原"),onlyauthor:wgULS("该页面只有一位编辑者参与编辑,无法回退","該頁面只有一位編輯者參與編輯,無法還原"),missingparams:wgULS('必须要有参数"title"或参数"pageid"之一','必須存在參數"title"或參數"pageid"之一'),notitle:wgULS('参数"title"必须被设置','參數"title"必須被設置'),notoken:wgULS('参数"token"必须被设置','參數"token"必須被設置'),nouser:wgULS('参数"user"必须被设置','參數"user"必須被設置')},loop=(o,n)=>{const e=$(n);e.data("href")||(e.data("href",e.attr("href")).removeAttr("href").attr("title",`${n.title}(启用自定义摘要)`).css("cursor","pointer").append("<sup>+</sup>").find("sup").on("click",o=>o.stopPropagation()),$(".ns-special")[0]&&e.text().includes("10")&&e.parent().text(wgULS("[超过10次的编辑]","[超過10次的編輯]")).attr("title","超过10次的编辑请使用撤销功能,以便检查差异(自定义摘要小工具)"),n.onmouseover=$.noop,n.onmouseout=$.noop,n.onmousedown=$.noop)};$(".mw-rollback-link a").each(loop);const e=new mw.Api;$(document.body).on("click",async o=>{const t=o.target;if(!$(t).is(".mw-rollback-link a")||$(t).closest(".jquery-confirmable-button-no")[0])return!0;const l=$(t),i=l.parent();if(l.data("href")||loop(0,t),!i.find(l)[0])return!1;if(mw.config.get("wgRollbacking"))return!1;const r=await oouiDialog.prompt(`<ul><li>${wgULS("回退操作的编辑摘要","還原操作的編輯摘要")}:<code>xxx//Rollback</code></li><li>${wgULS("空白则使用默认回退摘要","留空則使用默認的還原摘要")},${wgULS("取消则不进行回退","取消則不進行還原")}</li></ul><hr>${wgULS("请输入回退摘要","請輸入還原摘要")}:`,{title:"回退小工具",size:"medium",required:!1});if(null!==r){const o=new mw.Uri(l.data("href"));l.replaceWith(`<span id="rbing"><img src="https://img.moegirl.org.cn/common/d/d1/Windows_10_loading.gif" style="height: 1em; margin-top: -.25em;">${wgULS("正在回退中","正在還原")}……</span>`);const t=$("#rbing");$(".mw-rollback-link a").not(t).css({color:"#aaa","text-decoration":"none"}),mw.config.set("wgRollbacking",!0);const i=r?`${r} //Rollback`:"//Rollback";if(o.query.from)try{await e.post({action:"rollback",assertuser:mw.config.get("wgUserName"),title:o.query.title,user:o.query.from,summary:i,token:o.query.token,format:"json"}),t.css("color","green").html(`成功!${wgULS("将在","將在")}<span id="rbcount">3</span>秒${wgULS("内刷新","內重新整理")}`)}catch(o){const e=o instanceof Error?`${o} ${o.stack.split("\n")[1].trim()}`:$.isPlainObject(o)?JSON.stringify(o):"string"==typeof o&&Reflect.has(n,o)?n[o]:`${o}`;t.css("color","red").html(`${wgULS("错误","錯誤")}:${e}。${wgULS("将在","將在")}<span id="rbcount">3</span>${wgULS("秒内刷新","秒內重新整理")}`)}finally{(()=>{const o=$("#rbcount");let n=3;setInterval(()=>{0===--n&&window.location.reload(),o.text(n>0?n:"0")},1e3)})()}else o.query.summary=i,window.open(o.toString(),"_self")}return!1}),(new Image).src="https://img.moegirl.org.cn/common/d/d1/Windows_10_loading.gif";const t=document.querySelector(".mw-changeslist");t&&new MutationObserver(o=>{o.forEach(o=>{o.addedNodes.forEach(o=>{1===o.nodeType&&$(o).find(".mw-rollback-link a:not([data-href])").addBack(".mw-rollback-link a:not([data-href])").each(loop)})})}).observe(t,{childList:!0})});
/* </pre> */