MediaWiki:Gadget-rollback-summary.js:修订间差异
跳到导航
跳到搜索
imported>=海豚= 无编辑摘要 |
小 (→top:bad link repair, replaced: hmoegirl.com → hmoegirl.info) |
||
第22行: | 第22行: | ||
if (rollbackSummary !== null) $.ajax({ | if (rollbackSummary !== null) $.ajax({ | ||
type: 'POST', | type: 'POST', | ||
url: 'https://www.hmoegirl. | url: 'https://www.hmoegirl.info/api.php', | ||
beforeSend: function() { | beforeSend: function() { | ||
self.replaceWith('<span id="rbing"><img src="https://img.moegirl.org.cn/common/d/d1/Windows_10_loading.gif" style="height: 1em; margin-top: -.25em;">正在回退中……</span>'); | self.replaceWith('<span id="rbing"><img src="https://img.moegirl.org.cn/common/d/d1/Windows_10_loading.gif" style="height: 1em; margin-top: -.25em;">正在回退中……</span>'); |
2022年12月20日 (二) 16:16的最新版本
$(function() {
mw.config.set({
'wgRollbacking': false,
'wgRollbackTool': 'inited'
});
$.fn.extend({
getParamValue: function getParamValue(param) {
var href = this.data('href');
if (!href) return undefined;
return mw.util.getParamValue(param, href);
}
});
$('.mw-rollback-link a').each(loop);
$(document.body).on('click', function(event) {
if (!$(event.target).is('.mw-rollback-link a')) return true;
var self = $(event.target),
parent = self.parent();
if (!self.data('href')) loop.bind(event.target)();
if (!parent.find(self)[0]) return false;
if (mw.config.get('wgRollbacking')) return true;
var rollbackSummary = prompt('回退操作的编辑摘要【xxx//Rollback】\n【空白则使用默认回退摘要】\n【取消则不进行回退】:');
if (rollbackSummary !== null) $.ajax({
type: 'POST',
url: 'https://www.hmoegirl.info/api.php',
beforeSend: function() {
self.replaceWith('<span id="rbing"><img src="https://img.moegirl.org.cn/common/d/d1/Windows_10_loading.gif" style="height: 1em; margin-top: -.25em;">正在回退中……</span>');
self = $('#rbing');
$('.mw-rollback-link a').not(self).css({
color: '#aaa',
"text-decoration": 'none'
});
mw.config.set('wgRollbacking', true);
},
data: {
title: self.getParamValue('title'),
user: self.getParamValue('from'),
summary: rollbackSummary ? rollbackSummary + ' //Rollback' : '//Rollback',
token: self.getParamValue('token'),
action: 'rollback',
format: 'json'
},
error: function(eO, eM, eC) {
eC = eM ? eC + '(' + eM + ')' : eC;
self.css('color', 'red').html('错误:' + eC + '。将在<span id="rbcount">3</span>秒内刷新');
exit();
},
success: function(d) {
if (d.error) self.css('color', 'red').html('错误:已被回退。将在<span id="rbcount">3</span>秒内刷新');
else self.css('color', 'green').html('成功!将在<span id="rbcount">3</span>秒内刷新');
exit();
}
});
return false;
});
function exit() {
window.setInterval(function() {
var count = +$('#rbcount').text();
if (count-- == 1) window.location.reload();
$('#rbcount').text(count > 0 ? count : '0');
}, 1000);
}
function loop() {
var self = $(this);
self.data('href', self.attr('href')).removeAttr('href') //取消拖动链接回退
.attr('title', this.title + '(启用自定义摘要)').css('cursor', 'pointer').append('<sup>+</sup>');
if ($('.ns-special')[0] && self.text().indexOf('10') != -1) self.parent().text('[超过10次的编辑]').attr('title', '超过10次的编辑请使用撤销功能,以便检查差异');
}
});