mirror of
https://github.com/krateng/maloja.git
synced 2023-08-10 21:12:55 +03:00
Added extension settings to define server and API key
This commit is contained in:
parent
f1d1421374
commit
5cedde41a1
@ -210,10 +210,17 @@ function scrobble(artist,title,seconds) {
|
||||
console.log("Scrobbling " + artist + " - " + title + "; " + seconds + " seconds playtime")
|
||||
artiststring = encodeURIComponent(artist)
|
||||
titlestring = encodeURIComponent(title)
|
||||
APIKEY = "YDzcmp8JpYHCcvJbDOVT7nEDoyCEND6K" ///obviously this will not be hardcoded later
|
||||
var xhttp = new XMLHttpRequest();
|
||||
xhttp.open("POST","http://localhost:42010/db/newscrobble",true);
|
||||
xhttp.send("artist=" + artiststring + "&title=" + titlestring + "&duration=" + seconds + "&key=" + APIKEY)
|
||||
chrome.storage.local.get("apikey",function(result) {
|
||||
APIKEY = result["apikey"]
|
||||
chrome.storage.local.get("serverurl",function(result) {
|
||||
URL = result["serverurl"]
|
||||
var xhttp = new XMLHttpRequest();
|
||||
xhttp.open("POST",URL + "/db/newscrobble",true);
|
||||
xhttp.send("artist=" + artiststring + "&title=" + titlestring + "&duration=" + seconds + "&key=" + APIKEY)
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
function setUpdate() {
|
||||
|
@ -3,7 +3,7 @@
|
||||
"version": "0.1",
|
||||
"description": "Scrobbles tracks from Plex Web to your Maloja server",
|
||||
"manifest_version": 2,
|
||||
"permissions": ["activeTab", "declarativeContent","tabs","http://app.plex.tv/*","https://app.plex.tv/*"],
|
||||
"permissions": ["activeTab", "declarativeContent","tabs","storage","http://app.plex.tv/*","https://app.plex.tv/*"],
|
||||
"background":
|
||||
{
|
||||
"scripts":
|
||||
@ -19,7 +19,9 @@
|
||||
{
|
||||
"128":"icon128.png",
|
||||
"48":"icon48.png"
|
||||
}
|
||||
},
|
||||
"default_popup": "settings.html",
|
||||
"default_title": "Settings"
|
||||
},
|
||||
"icons":
|
||||
{
|
||||
|
16
scrobbler-vivaldi-plex/settings.html
Normal file
16
scrobbler-vivaldi-plex/settings.html
Normal file
@ -0,0 +1,16 @@
|
||||
<!doctype html />
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>Wat</title>
|
||||
<script type="text/javascript" src="settings.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="wat">
|
||||
<p>Server:</p>
|
||||
<input type="text" id="serverurl" value="http://localhost:42010" />
|
||||
<p>API key:</p>
|
||||
<input type="text" id="apikey" />
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
34
scrobbler-vivaldi-plex/settings.js
Normal file
34
scrobbler-vivaldi-plex/settings.js
Normal file
@ -0,0 +1,34 @@
|
||||
|
||||
document.addEventListener("DOMContentLoaded",function() {
|
||||
document.getElementById("serverurl").addEventListener("input",updateServer);
|
||||
document.getElementById("apikey").addEventListener("input",updateAPIKey);
|
||||
|
||||
|
||||
chrome.storage.local.get({"serverurl":"http://localhost:42010"},function(result) {
|
||||
document.getElementById("serverurl").value = result["serverurl"]
|
||||
});
|
||||
chrome.storage.local.get({"apikey":"BlackPinkInYourArea"},function(result) {
|
||||
document.getElementById("apikey").value = result["apikey"]
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
function updateServer() {
|
||||
|
||||
text = document.getElementById("serverurl").value
|
||||
|
||||
if (!text.startsWith("http://") & !text.startsWith("https://")) {
|
||||
document.getElementById("serverurl").style.backgroundColor = "pink";
|
||||
}
|
||||
else {
|
||||
document.getElementById("serverurl").style.backgroundColor = "white";
|
||||
chrome.storage.local.set({"serverurl":text})
|
||||
}
|
||||
}
|
||||
|
||||
function updateAPIKey() {
|
||||
text = document.getElementById("apikey").value
|
||||
chrome.storage.local.set({"apikey":text})
|
||||
}
|
Loading…
Reference in New Issue
Block a user