-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmsg-record-enhance.js
62 lines (61 loc) · 2.5 KB
/
msg-record-enhance.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
// ==UserScript==
// @name Message Record Enhance
// @description 查看转发的聊天记录中已知的和引用消息发送者 QQ,需要开启 LiteLoader Hook Vue
// @run-at forward
// @reactive false
// @version 0.2.0
// @homepageURL https://github.com/PRO-2684/Scriptio-user-scripts/#msg-record-enhance
// @author PRO_2684
// @license gpl-3.0
// ==/UserScript==
(function () {
const censoredUins = ["0", "1094950020"];
function setTitle(el, title, copy) {
if (!el) return;
el.title = title;
if (copy) {
el.addEventListener("dblclick", () => {
navigator?.clipboard?.writeText(copy);
});
}
}
function addHint(component) {
const el = component?.vnode?.el;
if (!el) return;
let sender;
if (el?.classList?.contains("reply-element")) { // 引用消息查看发送者
console.log("reply-element");
sender = component?.props?.msgElement?.replyElement?.senderUid;
const text = sender ? `发送者 QQ: ${sender} (双击复制)` : "未知发送者";
setTitle(el.querySelector(".reply-info"), text, sender);
} else if (el?.classList?.contains("message")) { // 已知发送者的消息
console.log("message");
const givenSender = component?.props?.msgRecord?.senderUin;
sender = censoredUins.includes(givenSender) ? null : givenSender;
if (sender) {
setTitle(el.querySelector(".avatar-span"), `发送者 QQ (双击复制): ${sender}`, sender);
} else {
const info = component?.props?.msgRecord?.multiTransInfo;
if (!info) return;
const anonId = info?.fromAnonId;
const avatarUrl = info?.fromFaceUrl;
if (anonId && avatarUrl) {
const avatar = el.querySelector(".avatar-span");
if (avatar) {
setTitle(avatar, `未知发送者\nAlt+Click 在浏览器打开头像\n标识 ID (双击复制): ${anonId}`, anonId);
avatar.addEventListener("click", (e) => {
if (e.altKey) {
scriptio.open("link", avatarUrl);
}
});
}
}
}
}
}
const vueMount = scriptio.vueMount;
function main() {
vueMount.push(addHint);
}
main();
})();