├── README.md ├── LICENSE └── awl.user.js /README.md: -------------------------------------------------------------------------------- 1 | # check-awl 2 | 用于检查B站评论是否被阿瓦隆拦截屏蔽 3 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 一心向晚 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /awl.user.js: -------------------------------------------------------------------------------- 1 | // ==UserScript== 2 | // @name B站阿瓦隆检测工具 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 https://*.bilibili.com/* 14 | // @icon https://www.google.com/s2/favicons?domain=bilibili.com 15 | 16 | // @grant none 17 | // ==/UserScript== 18 | class XMLHttp { 19 | request = function (param) { }; 20 | response = function (param) { }; 21 | } 22 | let http = new XMLHttp(); 23 | //拦截XMLHttpRequest 24 | function initXMLHttpRequest() { 25 | let open = XMLHttpRequest.prototype.open; 26 | XMLHttpRequest.prototype.open = function (...args) { 27 | let send = this.send; 28 | let _this = this; 29 | let post_data = []; 30 | this.send = function (...data) { 31 | post_data = data; 32 | return send.apply(_this, data); 33 | }; 34 | // 请求前拦截 35 | http.request(args); 36 | 37 | this.addEventListener( 38 | "readystatechange", 39 | function () { 40 | if (this.readyState === 4) { 41 | let config = { 42 | url: args[1], 43 | status: this.status, 44 | method: args[0], 45 | data: post_data, 46 | }; 47 | // 请求后拦截 48 | http.response({ config, response: this.response }); 49 | } 50 | }, 51 | false 52 | ); 53 | return open.apply(this, args); 54 | }; 55 | } 56 | (function () { 57 | 'use strict'; 58 | http.response = function (res) { 59 | if (res.config.url.includes("/x/v2/reply/add")) { 60 | let oid = res.config.data[0].match(/oid=(\d+)/)[1]; 61 | setTimeout(() => { 62 | chick(res.response, oid) 63 | }, 1000); 64 | } 65 | }; 66 | initXMLHttpRequest(); 67 | 68 | async function chick(response_str, oid) { 69 | let response_json = JSON.parse(response_str) 70 | if (response_json.data.reply.state != 0) { 71 | copy_delete_reply(response_json, oid); 72 | } 73 | else { 74 | const flags = await check_reply(response_json, oid) 75 | if (flags === true) return 76 | copy_delete_reply(response_json, oid); 77 | } 78 | } 79 | 80 | function check_reply(response_json, oid) { 81 | let api = "https://api.bilibili.com/x/v2/reply/jump"; 82 | let type = response_json.data.reply.type; 83 | // let oid = response_json.data.reply.oid; 84 | let rpid = response_json.data.reply.rpid; 85 | let url = `${api}?type=${type}&oid=${oid}&rpid=${rpid}`; 86 | let flags = new Promise((resolve, reject) => { 87 | fetch(url, { 88 | method: 'GET', 89 | }).then(res => res.json()).then(res => { 90 | var temp = false 91 | res.data.replies.forEach(reply => { 92 | if (reply.rpid == rpid) temp = true; 93 | else if (reply.replies != null) { 94 | reply.replies.forEach(reply => { 95 | if (reply.rpid == rpid) temp = true; 96 | }) 97 | } 98 | }) 99 | resolve(temp); 100 | }) 101 | }); 102 | return flags; 103 | } 104 | 105 | function copy_delete_reply(response_json, oid) { 106 | let r = confirm(`你的评论:\n${response_json.data.reply.content.message}\n被阿瓦隆屏蔽了,点击确定复制并删除\n(长评论小作文可能要过审才能显示,建议小作文显示被屏蔽点取消!!)`); 107 | if (r) { 108 | let api = "https://api.bilibili.com/x/v2/reply/del"; 109 | let type = response_json.data.reply.type; 110 | // let oid = response_json.data.reply.oid; 111 | let rpid = response_json.data.reply.rpid; 112 | let csrf = document.cookie.match(/bili_jct=([^;]+)/)[1]; 113 | fetch(api, { 114 | method: 'POST', 115 | body: `type=${type}&oid=${oid}&rpid=${rpid}&csrf=${csrf}`, 116 | headers: { 117 | 'Content-Type': 'application/x-www-form-urlencoded' 118 | }, 119 | credentials: "include" 120 | }).then(() => { 121 | navigator.clipboard.writeText(response_json.data.reply.content.message).then(() => { 122 | setTimeout(() => { 123 | document.getElementsByClassName('hot-sort')[0].click(); 124 | setTimeout(() => { 125 | document.getElementsByClassName('new-sort')[0].click(); 126 | }, 250); 127 | }, 500); 128 | }) 129 | }) 130 | } 131 | } 132 | })(); --------------------------------------------------------------------------------