blob: ba741a95dd00e78e3a881dc23b4ab1a88f547b27 (
plain)
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
|
const start = async () => {
// if there is no chat
if (document.querySelector("div[data-a-target=chat-input]") == null) {
return;
}
const channelName = getChannelName();
if (!channelName) {
return;
}
const emotes = {};
// fetching instances
const instances = ["alright.party"];
for (const instanceUrl of instances) {
let url = instanceUrl;
if (!url.startsWith("https://") && !url.startsWith("http://")) {
url = "https://" + url;
}
const data = await getTinyEmotesUserByName(url, channelName);
const user = data.data;
// adding emotes
const emote_set = user.emote_sets.find((x) => x.id === user.active_emote_set_id);
for (const emote of emote_set.emotes) {
emotes[emote.code] = {
miniatureurl: `${url}/static/userdata/emotes/${emote.id}/1x.${emote.ext}`,
fullurl: `${url}/static/userdata/emotes/${emote.id}/3x.${emote.ext}`,
uploader: emote.uploaded_by ? emote.uploaded_by.username : "Anonymous*",
instance: instanceUrl,
code: emote.code
};
}
}
const observer = new MutationObserver(mutations => {
for (const m of mutations) {
m.addedNodes.forEach(node => {
if (node.nodeType !== 1) return;
const textEl = node.querySelector('[data-a-target=chat-message-text]');
if (textEl) {
replaceEmotes(textEl, emotes);
}
});
}
});
observer.observe(document.body, { childList: true, subtree: true });
};
function onPageReady(cb) {
if (document.readyState === 'complete' || document.readyState === 'interactive') {
cb();
} else {
document.addEventListener("DOMContentLoaded", db);
}
}
onPageReady(start);
|