User:WhitePhosphorus/js/all-in-one.js
外观
注意:保存之后,你必须清除浏览器缓存才能看到做出的更改。Google Chrome、Firefox、Microsoft Edge及Safari:按住⇧ Shift键并单击工具栏的“刷新”按钮。参阅Help:绕过浏览器缓存以获取更多帮助。
// 回退,封禁,删除,RD,不理会。
$(function () {
mw.loader.using(['mediawiki.util', 'mediawiki.api'], function() {
let config = {};
const work = function() {
let api = new mw.Api();
if (config.block) {
let data = {
action: 'block',
user: config.username,
expiry: config.blockDur,
reason: config.blockReason,
reblock: 1
};
if (config.blockAnon) data.anononly = 1;
if (config.blockAuto) data.autoblock = 1;
if (config.blockCreate) data.nocreate = 1;
if (!config.blockTalk) data.allowusertalk = 1;
if (config.blockMail) data.noemail = 1;
if (config.blockHide) data.hidename = 1;
api.postWithEditToken(data).done(() => mw.notify('The villain is blocked.')).fail(function(e) {
mw.notify('Failed to block the villain: ' + e);
console.log(e);
});
}
let untildate = new Date();
if (config.endtime === '1h') {
untildate.setHours(untildate.getHours() - 1);
} else if (config.endtime === 'inf') {
untildate = null;
} else {
// TODO: 2019年9月1日 (日) 21:47
untildate = new Date(config.endtime);
if (isNaN(untildate.getTime()))
config.isIP ? untildate.setHours(untildate.getHours() - 1) : (untildate = null);
}
data = {
action: 'query',
list: 'usercontribs',
ucuser: config.username,
uclimit: 'max'
// TODO: continue
};
if (untildate) data.ucend = untildate.toISOString();
api.get(data).done(function(data) {
let contribs = data.query;
if (!contribs) {
mw.notify('Failed to fetch the contribs!');
return;
}
contribs = contribs.usercontribs;
if (!contribs || !contribs.length) {
mw.notify('No contribs found.');
return;
}
let ids = {};
let creation = [];
for (let edit of contribs) {
if (edit.new === '') {
creation.push(edit.title);
} else {
if (ids[edit.title] === undefined) ids[edit.title] = [];
ids[edit.title].push(edit.revid);
}
}
for (let [title, idlist] of Object.entries(ids)) {
data = config.rollbackBot ? {markbot: 1} : {};
data.summary = config.rollbackShow ? '' : 'revert edits by <username hidden>';
api.rollback(title, config.username, data).done(function() {
mw.notify(`Page ${title} Reverted.`);
}).fail(function(e) {
mw.notify(`Failed to revert on the page ${title}: ${e}`);
console.log('revert', title, e);
}).always(function() {
if (config.rd) {
api.postWithEditToken({
action: 'revisiondelete',
type: 'revision',
ids: idlist,
hide: config.rdHides,
reason: config.rdReason,
suppress: config.os ? "yes" : "nochange"
}).done(() => mw.notify(`${idlist.length} revisions on page ${title} hidden.`)).fail(function(e) {
mw.notify(`Failed to hide revisions on ${title}: ${e}`);
console.log('revisiondelete', title, idlist, e);
});
}
});
}
if (config.massdel) {
for (let title of creation) {
api.postWithEditToken({
action: 'delete',
title: title,
reason: config.massdelReason
}).done(() => mw.notify(`Deleted page ${title}.`)).fail(function(e) {
mw.notify(`Failed to delete ${title}: ${e}`);
console.log('delete', title, e);
});
}
}
});
};
$(mw.util.addPortletLink('p-cactions', '#', '一条龙服务')).click(function (e) {
$('#content').html(`<form id="p4js-allinone-settings"><p>警告:不支持 IP 段。</p>
<label>用户名:<input type="text" style="width:100%" id="p4js-allinone-username"></label><br>
<label>编辑追溯期:<select id="p4js-allinone-endtime" onchange="this.value === 'other' ? $('#p4js-allinone-endtime-text').show() : $('#p4js-allinone-endtime-text').hide();">
<option value="1h">1小时</option>
<option value="inf">全部编辑</option>
<option value="other">手动输入时间戳(包含该时间戳)</option>
</select></label><input type="text" id="p4js-allinone-endtime-text" style="display:none;width:100%"><br>
<label>套餐(注册用户均为不限期):<select id="p4js-allinone-package">
<option value="hkp">HKP(傀儡,一周,禁讨论页,RD)</option>
<option value="hd">韩导(傀儡,一周,禁讨论页,RD)</option>
<option value="harbin">哈尔滨(傀儡,一周,不 RD)</option>
<option value="rabbit">🐰(代理,两年,不 RD)</option>
<option value="vand">一般 VOA(anonblock,一周,不 RD)</option>
</select></label><br>
<fieldset>
<legend>回退</legend>
<label><input type="checkbox" checked id="p4js-allinone-rollback-bot">标记回退为机器人编辑</label>
<label><input type="checkbox" checked id="p4js-allinone-rollback-show">在回退摘要中显示用户名</label>
</fieldset>
<fieldset>
<legend><label><input type="checkbox" checked id="p4js-allinone-block">封禁</label></legend>
<label>时长:<select id="p4js-allinone-blockdur" onchange="this.value === 'other' ? $('#p4js-allinone-blockdur-text').show() : $('#p4js-allinone-blockdur-text').hide();">
<option value="1 day">1日</option>
<option value="31 hours">31小时</option>
<option value="3 days">3日</option>
<option value="5 days">5日</option>
<option value="1 week">1周</option>
<option value="2 weeks">2周</option>
<option value="1 month">1个月</option>
<option value="3 months">3个月</option>
<option value="1 year">1年</option>
<option value="2 years">2年</option>
<option value="never">不限期</option>
<option value="other">其他</option>
</select></label><input type="text" id="p4js-allinone-blockdur-text" style="display:none">
<label>理由:<select id="p4js-allinone-blockreason" onchange="$('#p4js-allinone-blockreason-text')[0].value = $('#p4js-allinone-blockreason-text')[0].value || this.value;">
<option value="確認為[[Project:SOCK|傀儡]]或[[Project:MEAT|真人傀儡]]">確認為[[Project:SOCK|傀儡]]或[[Project:MEAT|真人傀儡]]</option>
<option value="[[Project:VOA|纯破坏用户]]">[[Project:VOA|纯破坏用户]]</option>
<option value="[[Project:VAN|破壞]]">[[Project:VAN|破壞]]</option>
<option value="[[Project:SOAP|散發廣告或宣傳]]">[[Project:SOAP|散發廣告或宣傳]]</option>
<option value="仅[[Project:SOAP|散发广告/宣传]]的用户">仅[[Project:SOAP|散发广告/宣传]]的用户</option>
<option value="{{blocked proxy}}<!--[[Template:blocked proxy|blocked proxy]]-->">{{blocked proxy}}</option>
<option value="{{Anonblock}}<!--[[Template:Anonblock|Anonblock]]-->">{{Anonblock}}</option>
<option value="">其他</option>
</select></label><br>
<input type="text" style="width:100%" id="p4js-allinone-blockreason-text">
<label><input type="checkbox" checked id="p4js-allinone-block-anononly">仅限匿名用户</label>
<label><input type="checkbox" checked id="p4js-allinone-block-auto">启用自动封禁</label>
<label><input type="checkbox" checked id="p4js-allinone-block-create">账户创建停用</label>
<label><input type="checkbox" checked id="p4js-allinone-block-talk">阻止编辑讨论页</label>
<label><input type="checkbox" id="p4js-allinone-block-mail">阻止发送电邮</label>
<label><input type="checkbox" id="p4js-allinone-block-hide">在封禁日志中隐藏用户名(监督员限定)</label>
</fieldset>
<fieldset>
<legend><label><input type="checkbox" checked id="p4js-allinone-massdel">批量删除页面</label></legend>
<select id="p4js-allinone-delreason" onchange="$('#p4js-allinone-delreason-text')[0].value += this.value; this.value = '';">
<option value="">選擇</option>
<option value="[[Project:CSD#G3|G3]]: 纯粹[[Project:VAN|破坏]]">[[Project:CSD#G3|G3]]: 纯粹[[Project:VAN|破坏]]</option>
<option value="[[Project:CSD#G11|G11]]: 明顯的[[Project:SOAP|廣告宣傳]]頁面,或只有相关人物或團體的聯繫方法的页面">[[Project:CSD#G11|G11]]: 明顯的[[Project:SOAP|廣告宣傳]]頁面,或只有相关人物或團體的聯繫方法的页面</option>
</select><br>
<input type="text" style="width:100%" id="p4js-allinone-delreason-text"><br>
</fieldset>
<fieldset>
<legend><label><input type="checkbox" checked id="p4js-allinone-rd">删除修订版本</label></legend>
<label><input type="checkbox" checked id="p4js-allinone-hide-content">隐藏版本文字</label>
<label><input type="checkbox" checked id="p4js-allinone-hide-summary">隐藏编辑摘要</label>
<label><input type="checkbox" id="p4js-allinone-hide-username">隐藏用户名</label><br>
<select id="p4js-allinone-rdreason" onchange="$('#p4js-allinone-rdreason-text')[0].value += this.value; this.value = '';">
<option value="">選擇</option>
<option value="[[Project:RD1|RD1]]:明显侵犯版权">RD1:明显侵犯版权</option>
<option value="[[Project:RD2|RD2]]:针对个人、团体或组织的严重侮辱、贬低或攻击性材料">RD2:针对个人、团体或组织的严重侮辱、贬低或攻击性材料</option>
<option value="[[Project:RD3|RD3]]:纯粹的扰乱性内容">RD3:纯粹的扰乱性内容</option>
<option value="[[Project:RD4|RD4]]:非公开的私人信息">RD4:非公开的私人信息</option>
<option value="[[Project:RD5|RD5]]:删除守则下的有效删除,使用RevisionDelete执行">RD5:删除守则下的有效删除,使用RevisionDelete执行</option>
<option value="[[Project:RD6|RD6]]:版本删除校正">RD6:版本删除校正</option>
<option value="[[Project:OS|OS1]]:移除未公开私人资料">OS1:移除未公开私人资料</option>
<option value="[[Project:OS|OS2]]:移除疑诽谤内容:维基媒体基金会要求">OS2:移除疑诽谤内容:维基媒体基金会要求</option>
<option value="[[Project:OS|OS2]]:移除疑诽谤内容:事实清楚而且没有保留需要">OS2:移除疑诽谤内容:事实清楚而且没有保留需要</option>
<option value="[[Project:OS|OS3]]:移除侵犯版权内容:维基媒体基金会要求">OS3:移除侵犯版权内容:维基媒体基金会要求</option>
<option value="[[Project:OS|OS4]]:攻击性用户名">OS4:攻击性用户名</option>
</select><br>
<input type="text" style="width:100%" id="p4js-allinone-rdreason-text"><br>
<label><input type="checkbox" id="p4js-allinone-os">监督(监督员限定)</label>
</fieldset>
<input type="submit" id="p4js-allinone-start" value="开始 [Enter]"></form>`);
$('#p4js-allinone-package').on('change', function(e) {
let isIP = mw.util.isIPAddress($('#p4js-allinone-username')[0].value);
if (this.value === 'hd') {
$('#p4js-allinone-blockdur').val('1 week');
$('#p4js-allinone-rd')[0].checked = true;
$('#p4js-allinone-block-anononly')[0].checked = true;
$('#p4js-allinone-block-talk')[0].checked = true;
$('#p4js-allinone-block-mail')[0].checked = true;
$('#p4js-allinone-blockreason').val('確認為[[Project:SOCK|傀儡]]或[[Project:MEAT|真人傀儡]]');
} else if (this.value === 'hkp') {
$('#p4js-allinone-blockdur').val('1 week');
$('#p4js-allinone-rd')[0].checked = true;
$('#p4js-allinone-block-anononly')[0].checked = true;
$('#p4js-allinone-block-talk')[0].checked = true;
$('#p4js-allinone-blockreason').val('確認為[[Project:SOCK|傀儡]]或[[Project:MEAT|真人傀儡]]');
} else if (this.value === 'harbin') {
$('#p4js-allinone-blockdur').val('1 week');
$('#p4js-allinone-rd')[0].checked = false;
$('#p4js-allinone-block-anononly')[0].checked = true;
$('#p4js-allinone-block-talk')[0].checked = false;
$('#p4js-allinone-blockreason').val('確認為[[Project:SOCK|傀儡]]或[[Project:MEAT|真人傀儡]]');
} else if (this.value === 'rabbit') {
$('#p4js-allinone-blockdur').val('2 years');
$('#p4js-allinone-rd')[0].checked = false;
$('#p4js-allinone-block-anononly')[0].checked = false;
$('#p4js-allinone-block-talk')[0].checked = false;
$('#p4js-allinone-blockreason').val(isIP ? '{{blocked proxy}}<!--[[Template:blocked proxy|blocked proxy]]-->' : '確認為[[Project:SOCK|傀儡]]或[[Project:MEAT|真人傀儡]]');
} else if (this.value === 'vand') {
$('#p4js-allinone-blockdur').val('1 week');
$('#p4js-allinone-rd')[0].checked = false;
$('#p4js-allinone-block-anononly')[0].checked = true;
$('#p4js-allinone-block-talk')[0].checked = false;
$('#p4js-allinone-blockreason').val(isIP ? '{{Anonblock}}<!--[[Template:Anonblock|Anonblock]]-->' : '[[Project:VOA|纯破坏用户]]');
}
if (!isIP) $('#p4js-allinone-blockdur').val('never');
});
$('#p4js-allinone-username').on('keyup', function(e) {
if (mw.util.isIPAddress(this.value)) {
$('#p4js-allinone-endtime').val('1h');
$('#p4js-allinone-blockdur').val('1 week');
$('#p4js-allinone-block-anononly').parent().show();
$('#p4js-allinone-block-auto').parent().hide();
$('#p4js-allinone-block-mail').parent().hide();
} else {
$('#p4js-allinone-endtime').val('inf');
$('#p4js-allinone-blockdur').val('never');
$('#p4js-allinone-block-anononly').parent().hide();
$('#p4js-allinone-block-auto').parent().show();
$('#p4js-allinone-block-mail').parent().show();
}
});
$('#p4js-allinone-rdreason-text').val('[[Project:RD3|RD3]]:纯粹的扰乱性内容');
$('#p4js-allinone-delreason-text').val('[[Project:CSD#G3|G3]]: 纯粹[[Project:VAN|破坏]]');
if (mw.config.get('wgCanonicalSpecialPageName') == 'Contributions') {
// fill the current username
$('#p4js-allinone-username')[0].value = mw.config.get('wgPageName').slice(mw.config.get('wgPageName').indexOf('/')+1);
}
$('#p4js-allinone-username').focus();
$('#p4js-allinone-username').keyup();
$('#p4js-allinone-start').click(function(e) {
e.preventDefault();
config.username = $('#p4js-allinone-username')[0].value;
if (!config.username) return;
config.isIP = mw.util.isIPAddress(config.username);
if ($('#p4js-allinone-endtime')[0].value === 'other') {
config.endtime = $('#p4js-allinone-endtime-text')[0].value || (config.isIP ? '1h' : 'inf');
} else {
config.endtime = $('#p4js-allinone-endtime')[0].value;
}
//config.rollback = $('#p4js-allinone-rollback')[0].checked;
config.rollbackBot = $('#p4js-allinone-rollback-bot')[0].checked;
config.rollbackShow = $('#p4js-allinone-rollback-show')[0].checked;
config.block = $('#p4js-allinone-block')[0].checked;
config.blockDur = $('#p4js-allinone-blockdur-text')[0].value || $('#p4js-allinone-blockdur')[0].value;
config.blockReason = $('#p4js-allinone-blockreason-text')[0].value;
if (!config.blockReason.includes($('#p4js-allinone-blockreason')[0].value)) {
config.blockReason = $('#p4js-allinone-blockreason')[0].value + (config.blockReason && ':' + config.blockReason);
}
config.blockAnon = config.isIP && $('#p4js-allinone-block-anononly')[0].checked;
config.blockAuto = !config.isIP && $('#p4js-allinone-block-auto')[0].checked;
config.blockCreate = $('#p4js-allinone-block-create')[0].checked;
config.blockTalk = $('#p4js-allinone-block-talk')[0].checked;
config.blockMail = !config.isIP && $('#p4js-allinone-block-mail')[0].checked;
config.blockHide = $('#p4js-allinone-block-hide')[0].checked;
config.massdel = $('#p4js-allinone-massdel')[0].checked;
config.massdelReason = $('#p4js-allinone-delreason-text')[0].value;
config.rd = $('#p4js-allinone-rd')[0].checked;
config.rdHides = '';
if ($('#p4js-allinone-hide-content')[0].checked) config.rdHides += 'content|';
if ($('#p4js-allinone-hide-summary')[0].checked) config.rdHides += 'comment|';
if ($('#p4js-allinone-hide-username')[0].checked) config.rdHides += 'user|';
config.rdReason = $('#p4js-allinone-rdreason-text')[0].value;
config.os = $('#p4js-allinone-os')[0].checked;
work();
});
});
});
});