Added better logging and browser support.

We still need to work on the Linux browser a bit.
This commit is contained in:
Markil3
2021-07-26 20:27:43 -07:00
parent 77c0b4fa67
commit 66ce116da4
14 changed files with 601 additions and 146 deletions

View File

@@ -1,29 +1,20 @@
var port = browser.runtime.connectNative("universal_music")
console.log("Hello from Universal Music addon!")
/*
On startup, connect to the "ping_pong" app.
*/
var port = browser.runtime.connectNative("universalmusic");
/**
* Sends a message to the application
*/
function writeMessage(message)
{
port.postMessage(message)
}
/*
Listen for messages from the app.
*/
port.onMessage.addListener((response) => {
console.log("Received: " + response);
});
/**
* Sends a message to the application
*/
function onAppMessage(message)
{
if ("command" in message)
{
switch (message["command"])
{
case "ping":
writeMessage({
"response": "ping"
});
break
}
}
}
port.onMessage.addListener(onAppMessage);
/*
On a click on the browser action, send the app a message.
*/
browser.browserAction.onClicked.addListener(() => {
console.log("Sending: ping");
port.postMessage("ping");
});

View File

@@ -1,7 +0,0 @@
{
"name": "universal_music",
"description": "A link between the Universal Music Player and the web browser.",
"path": "${LINK_PATH}",
"type": "stdio",
"allowed_extensions": ["universal_music@regis.edu"]
}

View File

@@ -13,7 +13,7 @@
},
"browser_specific_settings": {
"gecko": {
"id": "universal_music@regis.edu",
"id": "universalmusic@regis.edu",
"strict_min_version": "55.0"
}
},