// ==UserScript== // @name B站批量拉黑开屏广告 // @version 1.0.3 // @description 批量拉黑 // @note 更新于 2025年11月6日 // @author qcgzxw // @match https://*.bilibili.com/* // @license GNU GPLv3 // @run-at document-end // @grant GM_registerMenuCommand // @grant GM_addStyle // @grant GM_openInTab // @grant GM_setValue // @grant GM_getValue // @grant GM_xmlhttpRequest // @require https://cdn.jsdelivr.net/npm/jquery@3.6.0/dist/jquery.min.js // @namespace https://greasyfork.org/zh-CN/users/1192640-huaisha2049 // @downloadURL none // ==/UserScript== (function() { 'use strict'; // 从cookie中获取csrf_token var csrf_token = document.cookie.match(/(?<=bili_jct=).+?(?=;)/)[0]; // 需要拉黑的UID列表 const uid_list = [ 1356882480, 1082814196, 1919627194, 1957313739, 1817661914, 1627242161, 1859459400, 1826766269, 1926952280, 2103756604, 1987938455, ]; // 批量拉黑函数 function batch_block() { for (let i = 0; i < uid_list.length; i++) { setTimeout(function () { $.ajax({ url: '//api.bilibili.com/x/relation/modify', type: "post", xhrFields: { withCredentials: true // 携带跨域cookie }, data: { 'fid': uid_list[i], // 要拉黑的UP主UID 'act': 5, 're_src': 11, 'jsonp': 'jsonp', 'csrf': csrf_token // CSRF令牌 } }) console.log("拉黑的UP主页:https://space.bilibili.com/" + uid_list[i]) //输出日志 if(i===uid_list.length-1){ alert('已拉黑所有开屏广告用户ID,名单更新日期2023/11/03'); } }, i * 100) }; } // 执行批量拉黑操作 //batch_block(); function createStartButton() { // 创建一个按钮元素 var startButton = document.createElement('button'); // 设置按钮的文本 startButton.textContent = '批量拉黑开屏广告(内置名单截止:2023/11/03)'; // 设置按钮的样式(可选) startButton.style.position = 'fixed'; startButton.style.top = '500px'; startButton.style.right = '10px'; startButton.style.padding = '10px 20px'; startButton.style.backgroundColor = 'red'; startButton.style.color = 'white'; startButton.style.border = 'none'; startButton.style.cursor = 'pointer'; // 为按钮添加点击事件监听器 startButton.addEventListener('click', function() { // 当用户点击按钮时,执行批量拉黑操作 batch_block(); }); // 将按钮添加到页面的body元素中 document.body.appendChild(startButton); } // 执行创建开始按钮的操作 createStartButton(); console.log("代码来源: https://greasyfork.org/zh-CN/scripts/514102-b%E7%AB%99%E6%89%B9%E9%87%8F%E6%8B%89%E9%BB%91/code") })();