-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInjectYoutubeChatHome.js
More file actions
75 lines (66 loc) · 2.32 KB
/
InjectYoutubeChatHome.js
File metadata and controls
75 lines (66 loc) · 2.32 KB
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
70
71
72
73
74
75
//--------------------------------------- BOUNCING TRANSLATION -------------------------------------------
// BOUNCING INCOMING MESSAGE TO THE LIVE CHAT SUBMITTER
var sendBtn;
var ChatText;
function SendTextEnter(inputtext){
ChatText.textContent = inputtext.replaceAll("\\\"", "\"");
ChatText.dispatchEvent(new InputEvent("input"));
sendBtn.click();
}
function LatchChatBox(){
sendBtn = document.querySelector("#send-button button",);
ChatText = document.querySelector("#input.yt-live-chat-text-input-field-renderer",);
if ((sendBtn == null) || (ChatText == null)) {
spn.textContent = "Can't find message input.";
} else {
spn.textContent = "Synced and ready.";
OpenReceiver();
}
}
//=============================================================================================================
var ChatElementTarget = "chat-messages";
var spn = document.createElement('p');
spn.textContent = "Looking for the chatbox...";
spn.style.fontSize = '15px';
spn.style.background = 'black';
spn.style.color = 'white';
spn.style.margin = '3px 10px 3px 10px';
spn.style.width = "100%"
spn.style.textAlign = "center";
var ExtContainer = document.createElement('div');
ExtContainer.id = "Extcontainer";
ExtContainer.appendChild(spn);
function OpenReceiver() {
window.addEventListener('message', (e) => {
if (e.origin == "https://app.mchatx.org") {
if (e.data.n == "MChatXXMSync") {
if (ChatText) {
SendTextEnter(e.data.d);
}
}
}
});
}
function Load() {
if ((document.referrer == "https://app.mchatx.org/") && (window.location != parent.location)) {
var i = 0;
const intv = setInterval(() => {
i++;
var target = document.getElementById(ChatElementTarget);
if (target.length != 0){
if (document.getElementById("Extcontainer") != null){
var ExtcontainerTemp = document.getElementById("Extcontainer");
ExtcontainerTemp.parentNode.removeChild(ExtcontainerTemp);
}
target.prepend(ExtContainer);
LatchChatBox();
clearInterval(intv);
} if (i == 30){
clearInterval(intv);
}
}, 1000);
}
}
function LoadButtons() {
}
Load();