User:Bencmq/rollbackSummary.js
外观
注意:保存之后,你必须清除浏览器缓存才能看到做出的更改。Google Chrome、Firefox、Microsoft Edge及Safari:按住⇧ Shift键并单击工具栏的“刷新”按钮。参阅Help:绕过浏览器缓存以获取更多帮助。
// For description, see [[User:Mr.Z-man/rollbackSummary]]
//[[User:Mr.Z-man]]编写代码
function rollbackSummary() {
var hasRollback = document.getElementsByClassName("span.mw-rollback-link");
var wgULS = mw.config.get('wgULS');
if (hasRollback[0] && wgULS) {
mw.util.addPortletLink('p-cactions', 'javascript:setRollbackSummary()', wgULS("回退摘要","回退摘要"), "ca-rollbacksummary", wgULS("自定义回退编辑摘要","自定義回退編輯摘要"));
}
}
$(rollbackSummary);
function setRollbackSummary() {
summary = prompt(wgULS("将本页所有回退链接的自动编辑摘要更改为:","將本頁所有回退鏈接的自動編輯摘要更改為:"), "");
if (!summary) {
for (var i in document.links) {
if (document.links[i].href.indexOf('summary=') != -1) {
document.links[i].href = document.links[i].href.substring(0, document.links[i].href.indexOf('summary=')-1);
}
}
}
else {
summary = "&summary=" + encodeURIComponent(summary);
for (var i in document.links) {
if (document.links[i].href.indexOf('action=rollback') != -1) {
document.links[i].href += summary;
}
}
}
}