1
0
mirror of https://github.com/krateng/maloja.git synced 2023-08-10 21:12:55 +03:00

Added scrobbler functionality to selectively enable sites

This commit is contained in:
krateng 2022-11-24 00:10:33 +01:00
parent 95eaf0a3d6
commit 185a5b3e87
2 changed files with 28 additions and 14 deletions

View File

@ -11,7 +11,8 @@ const ALWAYS_SCROBBLE_SECONDS = 60*3;
// Longer songs are always scrobbled when playing at least 2 minutes // Longer songs are always scrobbled when playing at least 2 minutes
pages = { pages = {
"Plex Web":{ "plex":{
"name":"Plex",
"patterns":[ "patterns":[
"https://app.plex.tv", "https://app.plex.tv",
"http://app.plex.tv", "http://app.plex.tv",
@ -20,31 +21,36 @@ pages = {
], ],
"script":"plex.js" "script":"plex.js"
}, },
"YouTube Music":{ "ytmusic":{
"name":"YouTube Music",
"patterns":[ "patterns":[
"https://music.youtube.com" "https://music.youtube.com"
], ],
"script":"ytmusic.js" "script":"ytmusic.js"
}, },
"Spotify Web":{ "spotify":{
"name":"Spotify",
"patterns":[ "patterns":[
"https://open.spotify.com" "https://open.spotify.com"
], ],
"script":"spotify.js" "script":"spotify.js"
}, },
"Bandcamp":{ "bandcamp":{
"name":"Bandcamp",
"patterns":[ "patterns":[
"bandcamp.com" "bandcamp.com"
], ],
"script":"bandcamp.js" "script":"bandcamp.js"
}, },
"Soundcloud":{ "soundcloud":{
"name":"Soundcloud",
"patterns":[ "patterns":[
"https://soundcloud.com" "https://soundcloud.com"
], ],
"script":"soundcloud.js" "script":"soundcloud.js"
}, },
"Navidrome":{ "navidrome":{
"name":"Navidrome",
"patterns":[ "patterns":[
"https://navidrome.", "https://navidrome.",
"http://navidrome." "http://navidrome."
@ -90,13 +96,21 @@ function onTabUpdated(tabId, changeInfo, tab) {
patterns = pages[key]["patterns"]; patterns = pages[key]["patterns"];
for (var i=0;i<patterns.length;i++) { for (var i=0;i<patterns.length;i++) {
if (tab.url.includes(patterns[i])) { if (tab.url.includes(patterns[i])) {
console.log("New page on tab " + tabId + " will be handled by new " + key + " manager!");
tabManagers[tabId] = new Controller(tabId,key);
updateTabNum();
return
//chrome.tabs.executeScript(tab.id,{"file":"sitescripts/" + pages[key]["script"]})
// check if we even like that page
chrome.storage.local.get(["service_active_" + key],function(result){
if (result["service_active_" + key]) {
console.log("New page on tab " + tabId + " will be handled by new " + key + " manager!");
tabManagers[tabId] = new Controller(tabId,key);
updateTabNum();
//chrome.tabs.executeScript(tab.id,{"file":"sitescripts/" + pages[key]["script"]})
}
else {
console.log("New page on tab " + tabId + " is " + key + ", not enabled!");
}
});
return;
} }
} }
} }
@ -127,10 +141,10 @@ function onInternalMessage(request,sender) {
for (tabId in tabManagers) { for (tabId in tabManagers) {
manager = tabManagers[tabId] manager = tabManagers[tabId]
if (manager.currentlyPlaying) { if (manager.currentlyPlaying) {
answer.push([manager.page,manager.currentArtist,manager.currentTitle]); answer.push([pages[manager.page]['name'],manager.currentArtist,manager.currentTitle]);
} }
else { else {
answer.push([manager.page,null]); answer.push([pages[manager.page]['name'],null]);
} }
} }

View File

@ -1,6 +1,6 @@
{ {
"name": "Maloja Scrobbler", "name": "Maloja Scrobbler",
"version": "1.11", "version": "1.12",
"description": "Scrobbles tracks from various sites to your Maloja server", "description": "Scrobbles tracks from various sites to your Maloja server",
"manifest_version": 2, "manifest_version": 2,
"permissions": [ "permissions": [