diff --git a/extension/_locales/en/messages.json b/extension/_locales/en/messages.json --- a/extension/_locales/en/messages.json +++ b/extension/_locales/en/messages.json @@ -31,6 +31,15 @@ "message": "Lets you control video and audio players in websites using the Media Controller plasmoid." }, + "options_plugin_mpris_media_sessions_title": { + "description": "Title for MediaSessions API Control plugin", + "message": "Enhanced Media Controls" + }, + "options_plugin_mpris_media_sessions_description": { + "description": "Description for MediaSessions API Control plugin", + "message": "Extract metadata and thumbnails of currently playing content. (Experimental)" + }, + "options_plugin_kdeconnect_title": { "description": "Title for KDE Connect plugin", "message": "Send via KDE Connect" diff --git a/extension/constants.js b/extension/constants.js --- a/extension/constants.js +++ b/extension/constants.js @@ -1,5 +1,6 @@ /* Copyright (C) 2017 Kai Uwe Broulik + Copyright (C) 2018 David Edmundson This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as @@ -19,6 +20,9 @@ mpris: { enabled: true }, + mprisMediaSessions: { + enabled: false + }, kdeconnect: { enabled: true }, diff --git a/extension/content-script.js b/extension/content-script.js --- a/extension/content-script.js +++ b/extension/content-script.js @@ -1,5 +1,6 @@ /* Copyright (C) 2017 Kai Uwe Broulik + Copyright (C) 2018 David Edmundson This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as @@ -58,20 +59,33 @@ } }); +var storage = (IS_FIREFOX ? chrome.storage.local : chrome.storage.sync); + +storage.get(DEFAULT_EXTENSION_SETTINGS, function (items) { + if (items.breezeScrollBars.enabled) { + loadBreezeScrollBars(); + } + if (items.mpris.enabled) { + loadMpris(); + if (items.mprisMediaSessions.enabled) { + loadMediaSessionsShim(); + } + } +}); + // BREEZE SCROLL BARS // ------------------------------------------------------------------------ // -if (!IS_FIREFOX) { - chrome.storage.sync.get(DEFAULT_EXTENSION_SETTINGS, function (items) { - if (items.breezeScrollBars.enabled) { - var linkTag = document.createElement("link"); - linkTag.rel = "stylesheet"; - linkTag.href = chrome.extension.getURL("breeze-scroll-bars.css"); - (document.head || document.documentElement).appendChild(linkTag); - } - }); +function loadBreezeScrollBars() { + if (!IS_FIREFOX) { + var linkTag = document.createElement("link"); + linkTag.rel = "stylesheet"; + linkTag.href = chrome.extension.getURL("breeze-scroll-bars.css"); + (document.head || document.documentElement).appendChild(linkTag); + } } + // MPRIS // ------------------------------------------------------------------------ // @@ -340,54 +354,55 @@ } } -document.addEventListener("DOMContentLoaded", function() { - - registerAllPlayers(); - - // TODO figure out somehow when a