-
Notifications
You must be signed in to change notification settings - Fork 0
/
elm-import.js
27 lines (25 loc) · 1.06 KB
/
elm-import.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
document.addEventListener("DOMContentLoaded", function () {
var div = document.getElementById("elm-main");
chrome.storage.local.get(['streamKey', 'serverUrl', 'liveStreamingPageUrl'], function(items) {
const app = Elm.Main.init({
node: div,
flags: {
url: window.location.href,
title: document.title,
streamKey: items.streamKey || '',
serverUrl: items.serverUrl || '',
liveStreamingPageUrl: items.liveStreamingPageUrl || ''
}
});
// Function to send messages to the content script
app.ports.sendMessageToContentScript.subscribe((message) => {
chrome.runtime.sendMessage(message, (response) => {
if (response) {
app.ports.receiveMessageFromContentScript.send(response);
} else if (chrome.runtime.lastError != null) {
console.error('Error receiving response:', chrome.runtime.lastError);
}
});
});
});
});