油猴脚本来自:https://github.com/scpwiki/easy-ban-script
并经过了汉化
/*
* Wikidot 简易撤销/封禁脚本
*
* 说明参考:https://05command.wikidot.com/user-scripts
*
* 原作者:aismallard
* 汉化:H_W_0
*/
// ==UserScript==
// @name Wikidot 简易撤销/封禁脚本
// @description 方便管理员撤销和封禁用户
// @version v0.2.0
// @updateURL https://github.com/scpwiki/easy-ban-script/raw/main/user-info.user.js
// @downloadURL https://github.com/scpwiki/easy-ban-script/raw/main/user-info.user.js
// @match https://*.wikidot.com/system:user/*
// ==/UserScript==
const CSS = `
#easy-ban-userscript {
border: 1px darkred solid;
padding: 0.5em;
}
#easy-ban-userscript legend {
font-weight: bold;
}
#easy-ban-userscript-error {
color: red;
font-weight: bold;
}
#easy-ban-userscript-ban-reason {
margin-left: 0.25em;
width: 70%;
}
#easy-ban-userscript button {
display: inline-block;
padding: 5px 10px 5px 10px;
text-align: center;
color: #ffffff;
background-color: #d9534f;
border-color: #d43f3a;
}
#easy-ban-userscript button:disabled {
filter: grayscale(1);
}
#easy-ban-userscript .danger-zone {
border: 1px darkred solid;
padding: 0.75em;
margin: 0.5em;
}
`;
const JS = `
const EASYBAN = {
escapeHtml: function escapeHtml(text) {
return text
.replace(/&/g, "&")
.replace(/</g, "<")
.replace(/>/g, ">")
.replace(/"/g, """)
.replace(/'/g, "'");
},
showError: function(message) {
const element = document.getElementById('easy-ban-userscript-error');
if (element === null) {
throw new Error('尝试显示错误时未找到错误元素:' + message);
}
element.innerText = message;
if (message) {
throw new Error(message);
}
},
showSuccess: function(message) {
EASYBAN.showError(''); // 清除错误信息
const win = new OZONE.dialogs.SuccessBox();
win.content = message;
win.show();
},
showConfirm: function(actionName, content, callback) {
const win = new OZONE.dialogs.ConfirmationDialog();
win.content = content;
win.buttons = ['取消', actionName];
win.addButtonListener(actionName, callback);
win.addButtonListener('取消', win.close);
win.show();
},
getUsername: function() {
const element = document.querySelector('h1.profile-title');
return element.innerText.trim();
},
runRevoke: function(userId) {
const username = EASYBAN.getUsername();
EASYBAN.showConfirm(
'撤销成员资格',
'你确定要 👢 <strong style="color: teal">撤销</strong> 用户 <strong>' + username + '</strong>(用户ID ' + userId + ')并将其从站点中移除吗?',
async () => {
await EASYBAN.runRevokeInner(userId);
EASYBAN.showSuccess('成员已移除')
},
);
},
runBan: function(userId) {
const reasonElement = document.getElementById('easy-ban-userscript-ban-reason');
if (reasonElement === null) {
throw new Error('未找到封禁原因输入框');
}
const reason = reasonElement.value;
if (!reason.trim()) {
// 要求必须提供封禁原因
EASYBAN.showError('未提供封禁原因');
}
const username = EASYBAN.getUsername();
EASYBAN.showConfirm(
'执行封禁',
'你确定要 ❌ <strong style="color: red">封禁</strong> 用户 <strong>' + username + '</strong>(用户ID ' + userId + '),原因如下:<br><code>' + EASYBAN.escapeHtml(reason) + '</code>',
async () => {
await EASYBAN.runBanInner(userId, reason);
EASYBAN.showSuccess('封禁已添加');
},
);
},
runRevokeInner: function(userId) {
return new Promise((resolve) => {
const params = {
action: 'ManageSiteMembershipAction',
event: 'removeMember',
user_id: userId,
};
OZONE.ajax.requestModule(null, params, resolve);
});
},
runBanInner: async function(userId, reason) {
// 先撤销成员资格,避免出现"用户仍是站点成员"的错误
await EASYBAN.runRevokeInner(userId);
// 然后执行实际的封禁操作
return new Promise((resolve) => {
const params = {
action: 'ManageSiteBlockAction',
event: 'blockUser',
userId,
reason,
};
OZONE.ajax.requestModule(null, params, resolve);
});
},
};
`;
function getUserId() {
const element = document.querySelector('a.btn.btn-default.btn-xs');
if (element === null) {
throw new Error('未选择用户或页面结构无效');
}
const userIdRegex = /https?:\/\/www\.wikidot\.com\/account\/messages#\/new\/(\d+)/;
const matches = element.href.match(userIdRegex);
if (matches === null) {
throw new Error(`私信链接不符合正则表达式:${element.href}`);
}
return matches[1];
}
function toggleDangerZone() {
const checkbox = document.getElementById('easy-ban-userscript-lock');
const disabled = checkbox.checked;
const elements = document.querySelectorAll('#easy-ban-userscript .can-lock');
for (let i = 0; i < elements.length; i++) {
elements[i].disabled = disabled;
}
}
function setup() {
// 获取当前用户ID
const userId = getUserId();
// 添加样式
const styleSheet = document.createElement('style');
styleSheet.innerHTML = CSS;
document.head.appendChild(styleSheet);
// 添加脚本
const scriptBlock = document.createElement('script');
scriptBlock.type = 'text/javascript';
scriptBlock.innerHTML = JS;
document.head.appendChild(scriptBlock);
// 构建界面
const fieldset = document.createElement('fieldset');
fieldset.id = 'easy-ban-userscript';
const legend = document.createElement('legend');
legend.innerText = '用户管理';
const lockContainer = document.createElement('div');
lockContainer.classList.add('danger-zone');
const lockCheckbox = document.createElement('input');
lockCheckbox.id = 'easy-ban-userscript-lock';
lockCheckbox.type = 'checkbox';
lockCheckbox.checked = true;
lockContainer.addEventListener('click', () => toggleDangerZone());
lockContainer.appendChild(lockCheckbox);
const lockLabel = document.createElement('label');
lockLabel.for = 'easy-ban-userscript-lock';
lockLabel.innerText = '防止误触锁';
lockContainer.appendChild(lockLabel);
const revokeButton = document.createElement('button');
revokeButton.classList.add('can-lock');
revokeButton.disabled = true;
revokeButton.innerText = '撤销成员';
revokeButton.setAttribute('onclick', `EASYBAN.runRevoke(${userId})`);
const banButton = document.createElement('button');
banButton.classList.add('can-lock');
banButton.disabled = true;
banButton.innerText = '封禁用户';
banButton.setAttribute('onclick', `EASYBAN.runBan(${userId})`);
const banReason = document.createElement('input');
banReason.id = 'easy-ban-userscript-ban-reason';
banReason.classList.add('can-lock');
banReason.disabled = true;
banReason.type = 'text';
banReason.placeholder = '封禁原因(必填)';
const errorText = document.createElement('div');
errorText.id = 'easy-ban-userscript-error';
errorText.classList.add('error-text');
fieldset.appendChild(legend);
fieldset.appendChild(lockContainer);
fieldset.appendChild(revokeButton);
fieldset.appendChild(banButton);
fieldset.appendChild(banReason);
fieldset.appendChild(errorText);
const parent = document.querySelector('.col-md-9');
parent.appendChild(fieldset);
}
setup();
另外如果你也想要为自己站制作一个这样的封禁页面,可以复制此页面代码。此页面代码最初来自SCP WIKI。