This repository has been archived by the owner on Feb 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 21
/
index.html
188 lines (163 loc) · 5.36 KB
/
index.html
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<noscript>
<meta
http-equiv="refresh"
content="5; url=https://chrome.google.com/webstore/detail/pop-out-jitsi-meet/boklbbjieahngbnhdmlhldjjibdnnbcn/"
/>
</noscript>
<title>Jitsi Meet</title>
<style>
* {
margin: 0;
padding: 0;
border: 0;
}
html,
body,
iframe {
min-width: 100vw;
min-height: 100vh;
}
html {
font-family: sans-serif;
color: white;
background: #000;
}
p {
margin: 1em;
}
a:visited {
color: blueviolet;
}
</style>
</head>
<body>
<p>
Download the Pop-out Jitsi Meet extension from the
<a
href="https://chrome.google.com/webstore/detail/pop-out-jitsi-meet/boklbbjieahngbnhdmlhldjjibdnnbcn/"
>Chrome Web Store</a
>.
</p>
<script type="module">
// In case of no script, redirect after 5 seconds.
const EXTENSION_ID = "boklbbjieahngbnhdmlhldjjibdnnbcn";
const DEV_EXTENSION_ID = "plimbkkbimiegedejekmlmffihphojde";
const hashValue = location.hash.substring(1);
var roomName;
var domain;
const willParseURLSearchParams = hashValue.indexOf("&") > -1;
if (willParseURLSearchParams) {
// The old URL format, with URLSearchParams.
// Jitsi Meet external API tries to parse these too,
// which throws errors.
const urlParams = new URLSearchParams(hashValue);
roomName = urlParams.get("room");
domain = urlParams.get("server");
} else {
// New URL format, hash router style
let tmp;
[tmp, domain, roomName] = hashValue.split("/");
}
if (!(roomName && domain)) {
// Room name or server value is missing,
// replace location immediately
location.replace(
"https://chrome.google.com/webstore/detail/pop-out-jitsi-meet/boklbbjieahngbnhdmlhldjjibdnnbcn/"
);
} else {
document.body.innerHTML = "";
const embedJitsi = () => {
const require = (url, callback) => {
const e = document.createElement("script");
e.src = url;
e.type = "text/javascript";
e.addEventListener("load", callback);
document.head.appendChild(e);
};
document.title += " | " + domain;
const hashHandler = () => {
if (window.location.hash !== "#" + hashValue) {
// Reload if we pasted a new URL in the URL bar
window.location.reload();
}
};
const setup = async () => {
if (willParseURLSearchParams) {
// Put back hash
window.location.hash = hashValue;
}
window.addEventListener("hashchange", hashHandler);
const { options } = await import(
"./extension/src/bg/jitsiConfig.js"
);
var displayName;
options.roomName = roomName;
options.parentNode = document.body;
const api = new JitsiMeetExternalAPI(domain, options);
api.on("displayNameChange", e => {
if (e.id === api._myUserID) {
// For local user
const newDisplayName = e.displayname.trim();
if (
newDisplayName !== "" &&
newDisplayName !==
options.interfaceConfigOverwrite.DEFAULT_REMOTE_DISPLAY_NAME
) {
displayName = e.displayname;
} else {
// Invalid, reset to previous
api.executeCommand("displayName", displayName);
}
}
});
api.on("videoConferenceJoined", e => {
// Get rid of ugly subject when using random characters for room name
displayName = e.displayName;
api.executeCommand("subject", " ");
});
};
if (hashValue && willParseURLSearchParams) {
// Remove hash temporarily so external API script won't try to parse it
history.pushState(
"",
document.title,
window.location.pathname + window.location.search
);
}
require(`https://${domain}/external_api.js`, setup);
};
if (window.chrome) {
const pingExtension = (id, failCallback) => {
chrome.runtime.sendMessage(
id,
{ type: "deepLink", roomName: roomName, domain: domain },
response => {
if (chrome.runtime.lastError) {
console.log(chrome.runtime.lastError.message);
if (typeof failCallback === "function") {
// Don't embed now, but try callback
return failCallback();
}
}
if (response && response.deepLink) {
// Will open as Pop-out Jitsi Meet conference
return;
}
embedJitsi();
}
);
};
pingExtension(EXTENSION_ID, () => {
pingExtension(DEV_EXTENSION_ID);
});
} else {
embedJitsi();
}
}
</script>
</body>
</html>