🏠 Home 

B站阿瓦隆检测工具2

用于检查评论是否被阿瓦隆拦截屏蔽


安装此脚本?
  1. // ==UserScript==
  2. // @name B站阿瓦隆检测工具2
  3. // @namespace https://github.com/XiaoMiku01/check-awl
  4. // @supportURL https://github.com/XiaoMiku01/check-awl
  5. // @version 0.1.6
  6. // @description 用于检查评论是否被阿瓦隆拦截屏蔽
  7. // @author 晓轩iMIKU-原作 带鱼-改
  8. // @license MIT
  9. // @compatible chrome 80 or later
  10. // @compatible edge 80 or later
  11. // @compatible firefox 74 or later
  12. // @compatible safari 13.1 or later
  13. // @match *://*.bilibili.com/*
  14. // @match *://*.hdslb.com/*
  15. // @icon https://www.google.com/s2/favicons?domain=bilibili.com
  16. // @grant none
  17. // ==/UserScript==
  18. (function () {
  19. 'use strict';
  20. // 拦截 fetch 请求
  21. const originalFetch = window.fetch;
  22. window.fetch = function (...args) {
  23. const fetchPromise = originalFetch.apply(this, args);
  24. // 检查请求的 URL 是否包含 '/x/v2/reply/add'
  25. if (args[0].includes('/x/v2/reply/add')) {
  26. fetchPromise.then(async response => {
  27. const clone = response.clone(); // 克隆响应,以便后续读取
  28. const resText = await clone.text();
  29. //console.log('/x/v2/reply/add!');
  30. let oid = '';
  31. if (args[1] && args[1].body) {
  32. const formData = new URLSearchParams(args[1].body);
  33. oid = formData.get('oid');
  34. }
  35. //console.log('oid=', oid, 'response=', resText);
  36. setTimeout(() => {
  37. check(resText, oid)
  38. }, 1000);
  39. }).catch(error => {
  40. console.error('Fetch error:', error);
  41. });
  42. }
  43. return fetchPromise;
  44. };
  45. // 检查评论状态
  46. async function check(response_str, oid) {
  47. let response_json = JSON.parse(response_str);
  48. if (response_json.data.reply.state !== 0) {
  49. copy_delete_reply(response_json, oid);
  50. } else {
  51. const exists = await check_reply(response_json, oid);
  52. if (exists === true) return;
  53. copy_delete_reply(response_json, oid);
  54. }
  55. }
  56. // 验证评论是否存在
  57. function check_reply(response_json, oid) {
  58. let api = "https://api.bilibili.com/x/v2/reply/jump";
  59. let type = response_json.data.reply.type;
  60. let rpid = response_json.data.reply.rpid;
  61. let url = `${api}?type=${type}&oid=${oid}&rpid=${rpid}`;
  62. return fetch(url, {
  63. method: 'GET',
  64. mode: 'cors',
  65. credentials: 'omit', // 不携带cookie,模拟未登录用户
  66. headers: {
  67. // 不要添加'priority'等自定义请求头
  68. // 浏览器会自动添加标准的请求头
  69. },
  70. referrer: document.referrer || window.location.href,
  71. referrerPolicy: 'no-referrer-when-downgrade'
  72. }).then(res => res.json()).then(res => {
  73. // 处理响应
  74. let exists = false;
  75. if (res.data && res.data.replies) {
  76. res.data.replies.forEach(reply => {
  77. if (reply.rpid === rpid) {
  78. exists = true;
  79. } else if (reply.replies) {
  80. reply.replies.forEach(subReply => {
  81. if (subReply.rpid === rpid) {
  82. exists = true;
  83. }
  84. });
  85. }
  86. });
  87. }
  88. return exists;
  89. }).catch(error => {
  90. console.error('Check reply error:', error);
  91. return false;
  92. });
  93. }
  94. // 提示用户删除被屏蔽的评论
  95. function copy_delete_reply(response_json, oid) {
  96. let message = response_json.data.reply.content.message;
  97. let confirmDelete = confirm(`你的评论:\n${message}\n被阿瓦隆屏蔽了,点击确定复制并删除\n(长评论小作文可能要过审才能显示,建议小作文显示被屏蔽点取消!!)`);
  98. if (confirmDelete) {
  99. let api = "https://api.bilibili.com/x/v2/reply/del";
  100. let type = response_json.data.reply.type;
  101. let rpid = response_json.data.reply.rpid;
  102. let csrf = document.cookie.match(/bili_jct=([^;]+)/)[1];
  103. fetch(api, {
  104. method: 'POST',
  105. body: `type=${type}&oid=${oid}&rpid=${rpid}&csrf=${csrf}`,
  106. headers: {
  107. 'Content-Type': 'application/x-www-form-urlencoded'
  108. },
  109. credentials: "include"
  110. }).then(() => {
  111. navigator.clipboard.writeText(message).then(() => {
  112. setTimeout(() => {
  113. document.getElementsByClassName('hot-sort')[0].click();
  114. setTimeout(() => {
  115. document.getElementsByClassName('new-sort')[0].click();
  116. }, 250);
  117. }, 500);
  118. });
  119. });
  120. }
  121. }
  122. })();