-
Notifications
You must be signed in to change notification settings - Fork 6
/
bilibili-censor-detect.user.js
69 lines (60 loc) · 2.21 KB
/
bilibili-censor-detect.user.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// ==UserScript==
// @name bilibili 评论审核检测
// @namespace https://github.com/sparanoid/userscript
// @supportURL https://github.com/sparanoid/userscript/issues
// @version 0.1.1
// @description bilibili 评论审核检测,可在回复/评论提交后实时反馈该内容是否对他人可见
// @author Sparanoid
// @license AGPL
// @compatible chrome 80 or later
// @compatible edge 80 or later
// @compatible firefox 74 or later
// @compatible safari 13.1 or later
// @match https://*.bilibili.com/*
// @icon https://experiments.sparanoid.net/favicons/v2/www.bilibili.com.ico
// @grant none
// @run-at document-start
// ==/UserScript==
// Debugging pages:
// - https://t.bilibili.com/594017148390748345
// - https://www.bilibili.com/read/cv13871002
// - https://space.bilibili.com/703007996/fans/follow
// - https://www.bilibili.com/video/BV1Ar4y1C77P
// - https://www.bilibili.com/video/BV1KL411g7om (colab)
window.addEventListener('load', () => {
const DEBUG = true;
const NAMESPACE = 'bilibili-censor-detect';
const apiBase = 'https://api.bilibili.com';
const feedbackUrl = 'https://t.bilibili.com/545085157213602473';
console.log(`${NAMESPACE} loaded`);
async function fetchResult(url = '', data = {}) {
const response = await fetch(url, {
credentials: 'include',
});
return response.json();
}
function debug(description = '', msg = '', force = false) {
if (DEBUG || force) {
console.log(`${NAMESPACE}: ${description}`, msg)
}
}
((open) => {
XMLHttpRequest.prototype.open = function() {
this.addEventListener("readystatechange", () => {
const url = this?.responseURL && new URL(this.responseURL);
// Check for reply API endpoints
if (url?.pathname === '/x/v2/reply/add') {
if (this.readyState === 4) {
const resp = JSON.parse(this.response);
const state = resp?.data?.reply?.state;
debug(state);
if (state !== 0) {
alert(`回复已被ban,状态码:${state}`)
}
}
}
}, false);
open.apply(this, arguments);
};
})(XMLHttpRequest.prototype.open);
}, false);