您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
贴吧一键封禁按钮
当前为
// ==UserScript== // @name Tieba Block Users Button // @namespace http://tampermonkey.net/ // @version 0.1 // @description 贴吧一键封禁按钮 // @author Jay_Lee // @match http*://tieba.baidu.com/bawu2/* // @grant none // @license MIT // ==/UserScript== (function () { 'use strict'; // 需要封禁的用户名列表,这里可以添加需要封禁的用户名 const usernames = [ 'AAAAAA', 'BBBBBB', 'CCCCCC', // 每个用户名使用英文引号包裹,两个用户名之间用英文逗号隔开 ]; const blockDays = 10; // 封禁天数,允许值1~10,默认10 const blockReason = '自动封禁中'; // 封禁理由,默认自动封禁中 // ⚠️以下内容如果您非专业请勿随意修改⚠️ const blockUri = 'https://tieba.baidu.com/pmc/blockid'; const cookie = document.cookie || ''; const FourmData = window.PageData.forum || {}; const UserData = window.PageData.user || {}; async function Block() { const chunkSize = 50; const chunks = []; for (let i = 0; i < usernames.length; i += chunkSize) { chunks.push(usernames.slice(i, i + chunkSize)); } let requestCount = 0; for (const userGroup of chunks) { requestCount++; const data = new URLSearchParams(); data.append('day', blockDays); data.append('fid', FourmData.forum_id || ''); data.append('tbs', UserData.tbs || ''); data.append('ie', 'gbk'); data.append('reason', blockReason); userGroup.forEach((username) => { data.append('user_name[]', username); }); try { const response = await fetch(blockUri, { method: 'POST', headers: { 'Content-Type': 'application/x-www-form-urlencoded', 'Cookie': cookie, }, body: data.toString(), credentials: 'include', }); const result = await response.json(); // 假设返回的是 JSON 格式 if (result.errno === 0) { // 操作成功 console.log(`Blocked users: ${userGroup.join(', ')}`, result); showNotification( `第${requestCount}次请求,本次封禁用户列表:\n\n${userGroup.join('、')}\n\n封禁成功`, '#00BFFF' // 成功背景色 ); } else { // 操作失败 console.warn(`Failed to block users: ${userGroup.join(', ')}`, result); showNotification( `第${requestCount}次请求,本次封禁用户列表:\n\n${userGroup.join('、')}\n\n封禁失败(错误信息:${result.errmsg})`, '#FFD700' // 失败背景色(黄色) ); } } catch (err) { console.error(`Error blocking users: ${userGroup.join(', ')}`, err); // 异常提示框 showNotification( `第${requestCount}次请求,本次封禁用户列表:\n\n${userGroup.join('、')}\n\n封禁失败(错误信息:${err.message})`, '#FF6347' // 异常背景色(红色) ); } // 每次请求后暂停 await sleep(2000); } } function showNotification(message, backgroundColor) { const notification = document.createElement('div'); notification.classList.add('notification'); notification.innerText = message; // 样式设置 Object.assign(notification.style, { position: 'fixed', right: '20px', zIndex: 10000, padding: '10px', backgroundColor, color: '#FFFFFF', border: '1px solid #000', borderRadius: '5px', boxShadow: '0 2px 5px rgba(0, 0, 0, 0.3)', fontSize: '14px', bottom: `${20 + document.querySelectorAll('.notification').length * 110}px`, // 动态计算位置 opacity: '1', // 初始透明度 transition: 'opacity 0.5s ease, transform 0.5s ease', // 添加透明度和位移的过渡效果 }); document.body.appendChild(notification); // 自动移除提示框并添加动画 setTimeout(() => { notification.style.opacity = '0'; // 渐隐效果 notification.style.transform = 'translateX(100%)'; // 向右移动抽出效果 setTimeout(() => { notification.remove(); // 重新调整剩余提示框的位置 document.querySelectorAll('.notification').forEach((notif, index) => { notif.style.bottom = `${20 + index * 110}px`; }); }, 500); // 等待动画完成后移除元素 }, 2000); } function sleep(ms) { return new Promise((resolve) => setTimeout(resolve, ms)); } function addButton() { const button = document.createElement('button'); button.innerText = '🥒执行封禁🥒'; button.style.position = 'fixed'; button.style.bottom = '20px'; // 调整到屏幕底部 button.style.left = '20px'; // 调整到屏幕左侧 button.style.zIndex = 9999; button.style.padding = '10px'; button.style.backgroundColor = '#00BFFF'; // 修改背景色 button.style.color = '#779977'; // 修改文字颜色 button.style.border = 'none'; button.style.borderRadius = '5px'; button.style.cursor = 'pointer'; button.addEventListener('click', Block); document.body.appendChild(button); } window.addEventListener('load', addButton); })();