MediaWiki:Gadget-rollback-summary.js
外观
注意:在发布之后,您可能需要清除浏览器缓存才能看到所作出的更改的影响。
- Firefox或Safari:按住Shift的同时单击刷新,或按Ctrl-F5或Ctrl-R(Mac为⌘-R)
- Google Chrome:按Ctrl-Shift-R(Mac为⌘-Shift-R)
- Edge:按住Ctrl的同时单击刷新,或按Ctrl-F5。
/**
* -------------------------------------------------------------------------
* !!! 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: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";$(()=>{const o=mw.config.get("wgUserGroups",[]);if(!o.includes("sysop")&&!o.includes("patroller"))return;mw.config.set({wgRollbacking:!1,wgRollbackTool:"inited"});const e={alreadyrolled:wgULS("已被回退","已被還原"),onlyauthor:wgULS("该页面只有一位编辑者参与编辑,无法回退","該頁面只有一位編輯者參與編輯,無法還原"),missingparams:wgULS('必须要有参数"title"或参数"pageid"之一','必須存在參數"title"或參數"pageid"之一'),notitle:wgULS('参数"title"必须被设置','參數"title"必須被設置'),notoken:wgULS('参数"token"必须被设置','參數"token"必須被設置'),nouser:wgULS('参数"user"必须被设置','參數"user"必須被設置')},loop=(o,e)=>{const n=$(e);n.data("href",n.attr("href")).removeAttr("href").attr("title",`${e.title}(启用自定义摘要)`).css("cursor","pointer").append("<sup>+</sup>"),$(".ns-special")[0]&&n.text().includes("10")&&n.parent().text(wgULS("[超过10次的编辑]","[超過10次的編輯]")).attr("title","超过10次的编辑请使用撤销功能,以便检查差异(自定义摘要小工具)"),e.onmouseover=$.noop,e.onmouseout=$.noop,e.onmousedown=$.noop};$(".mw-rollback-link a").each(loop);const n=new mw.Api;$(document.body).on("click",async o=>{const t=o.target;if(!$(t).is(".mw-rollback-link a"))return!0;const i=$(t),l=i.parent();if(i.data("href")||loop(0,t),!l.find(i)[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(i.data("href"));i.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 l=r?`${r} //Rollback`:"//Rollback";if(o.query.from)try{await n.post({action:"rollback",assertuser:mw.config.get("wgUserName"),title:o.query.title,user:o.query.from,summary:l,token:o.query.token,format:"json"}),t.css("color","green").html(`成功!${wgULS("将在","將在")}<span id="rbcount">3</span>秒${wgULS("内刷新","內重新整理")}`)}catch(o){const n=o instanceof Error?`${o} ${o.stack.split("\n")[1].trim()}`:$.isPlainObject(o)?JSON.stringify(o):"string"==typeof o&&Reflect.has(e,o)?e[o]:`${o}`;t.css("color","red").html(`${wgULS("错误","錯誤")}:${n}。${wgULS("将在","將在")}<span id="rbcount">3</span>${wgULS("秒内刷新","秒內重新整理")}`)}finally{(()=>{const o=$("#rbcount");let e=3;setInterval(()=>{0===--e&&window.location.reload(),o.text(e>0?e:"0")},1e3)})()}else o.query.summary=l,window.open(o.toString(),"_self")}return!1}),(new Image).src="https://img.moegirl.org.cn/common/d/d1/Windows_10_loading.gif"});
/* </pre> */