-
Notifications
You must be signed in to change notification settings - Fork 0
/
BiliBili Live Room WebSocket Proxy.user.js
54 lines (52 loc) · 2.07 KB
/
BiliBili Live Room WebSocket Proxy.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
// ==UserScript==
// @name BiliBili Live Room WebSocket Proxy
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author Shugen
// @include /^https?:\/\/live\.bilibili\.com\//
// @grant none
// ==/UserScript==
(function () {
'use strict';
if (window.DanmakuWebSocket) {
window.__DanmakuWebSocket = window.DanmakuWebSocket;
}
if (!window.BiliBiliOweMe300000 || !Array.isArray(window.BiliBiliOweMe300000)) {
window.BiliBiliOweMe300000 = []
};
Object.defineProperty(window, "DanmakuWebSocket", {
set: function (value) {
var handler = {
construct: function (target, args) {
debugger;
window.latestReceiver = args[0].onReceivedMessage;
args[0].__onReceivedMessage = args[0].onReceivedMessage;
args[0].onReceivedMessage = function () {
//console.log("received Messages:",arguments[0]);
if (!window.BiliBiliOweMe300000 || !Array.isArray(window.BiliBiliOweMe300000)) {
window.BiliBiliOweMe300000 = []
};
if (window.BiliBiliOweMe300000.length > 0) {
for (let i = 0; i < window.BiliBiliOweMe300000.length; i++) {
if (!window.BiliBiliOweMe300000[i](arguments[0])) { return; }
}
}
args[0].__onReceivedMessage.apply(this, arguments)
}
var obj = Object.create(value.prototype);
this.apply(target, obj, args);
return obj;
},
apply: function (target, that, args) {
value.apply(that, args);
}
};
return this.__DanmakuWebSocket = new Proxy(value, handler)
},
get: function () {
return this.__DanmakuWebSocket
}
}
);
})();