Created page with "// Register-to-delete tool for EnMGP, modified from zhmoe:MediaWiki:Gadget-registerToDelete.js // Alert: only able/allowed to use by patrollers or higher authority // Note..." |
mNo edit summary |
||
(One intermediate revision by the same user not shown) | |||
Line 1: | Line 1: | ||
// Register-to-delete tool for EnMGP, modified from [[zhmoe:MediaWiki:Gadget-registerToDelete.js]] | // Register-to-delete tool for EnMGP, modified from [[zhmoe:MediaWiki:Gadget-registerToDelete.js]] | ||
// Alert: only able/allowed to use by patrollers or higher authority | // Alert: only able/allowed to use by patrollers or higher authority | ||
// Note: instructions are not translated totally | // Note: instructions are not translated totally; plus, if you find any mistake in my translation, correct it as you will. | ||
// Usage: add the following code in [[Special:MyPage/common.js]]: mw.loader.load('https://en.moegirl.org.cn/index.php?title=User:C8H17OH/registerToDelete.js&action=raw&ctype=text/javascript'); | // Usage: add the following code in [[Special:MyPage/common.js]]: mw.loader.load('https://en.moegirl.org.cn/index.php?title=User:C8H17OH/registerToDelete.js&action=raw&ctype=text/javascript'); | ||
Line 16: | Line 16: | ||
text: '挂删' | text: '挂删' | ||
}).on('click', function() { | }).on('click', function() { | ||
var reason = prompt('挂删的理由【将会替换全文内容】\n【空白则使用默认理由(Out of | var reason = prompt('挂删的理由【将会替换全文内容】\n【空白则使用默认理由(Out of scope or low potential value)】\n【取消则不进行挂删】:'), | ||
self = $(this); | self = $(this); | ||
if (reason === null) return; | if (reason === null) return; | ||
if (reason === '') reason = 'Out of | if (reason === '') reason = 'Out of scope or low potential value'; | ||
var loadingBox = $('<div/>', { | var loadingBox = $('<div/>', { | ||
css: { | css: { |
// Register-to-delete tool for EnMGP, modified from [[zhmoe:MediaWiki:Gadget-registerToDelete.js]]
// Alert: only able/allowed to use by patrollers or higher authority
// Note: instructions are not translated totally; plus, if you find any mistake in my translation, correct it as you will.
// Usage: add the following code in [[Special:MyPage/common.js]]: mw.loader.load('https://en.moegirl.org.cn/index.php?title=User:C8H17OH/registerToDelete.js&action=raw&ctype=text/javascript');
// <pre>
$(function() {
var self = $('#p-cactions .menu ul');
if (!self.find('li')[0] || $('.willBeDeleted')[0] || mw.config.get('wgUserGroups').indexOf('patroller') === -1) return;
$('<a/>', {
attr: {
href: "#",
title: "挂删本页[alt-shift-d]",
accesskey: 'd'
},
text: '挂删'
}).on('click', function() {
var reason = prompt('挂删的理由【将会替换全文内容】\n【空白则使用默认理由(Out of scope or low potential value)】\n【取消则不进行挂删】:'),
self = $(this);
if (reason === null) return;
if (reason === '') reason = 'Out of scope or low potential value';
var loadingBox = $('<div/>', {
css: {
position: 'fixed',
top: '0',
left: '0',
height: '100vh',
width: '100vw',
transition: 'opacity .73s linear',
color: 'black',
'padding-top': '49vh',
'background-color': 'rgba(255,255,255,0.73)',
'text-align': 'center'
}
}).append('<img src="https://static.mengniang.org/common/d/d1/Windows_10_loading.gif" style="height: 1em; margin-top: -.25em;">正在挂删中……'),
reasonText = reason ? '|' + reason : '',
api = new mw.Api();
loadingBox.endOut = function endOut() {
this.css('color', 'red').text('挂删失败……').delay(1000).queue(function() {
$(this).css('opacity', '0').delay(730).queue(function() {
$(this).remove();
$(document.body).css('overflow', 'auto');
$(this).dequeue();
});
$(this).dequeue();
});
};
$(document.body).append(loadingBox).css('overflow', 'hidden');
api.postWithToken('csrf', {
action: 'edit',
format: 'json',
title: mw.config.get('wgPageName'),
text: '<noinclude>{{Awaiting deletion' + reasonText + '|user=' + mw.config.get("wgUserName") + '}}</noinclude>',
summary: 'Register to delete:' + reason,
nocreate: true,
watchlist: 'preferences'
}).then(function(d) {
if (d.error) return loadingBox.endOut();
loadingBox.css('color', 'green').text('挂删成功!即将刷新……');
window.setTimeout(function() {
window.location.reload();
}, 730)
}, loadingBox.endOut.bind(loadingBox));
}).appendTo($('<li/>', {
attr: {
id: 'ca-registerToDelete'
}
}).prependTo(self));
});
// </pre>