--- /dev/null
+/node_modules/
+/dist/
+/package-lock.json
--- /dev/null
+*************************************
+playVideoOnDreambox Firefox extension
+*************************************
+
+Firefox__ browser addon (extension) that adds a "Play on Dreambox" button to the
+toolbar.
+Pressing it plays the video of the current tab on your Dreambox__ satellite
+receiver.
+
+Works fine with a Dreambox `DM7080 HD`__.
+
+You can also right-click a link to a video page and select
+"Play linked video on Dreambox".
+That way you don't even need to open video detail pages.
+
+__ https://www.mozilla.org/firefox
+__ http://www.dream-multimedia-tv.de/products
+__ http://www.dream-multimedia-tv.de/dm7080-hd
+
+.. contents::
+
+
+Features
+========
+- Toolbar button to play the video on the current page
+- Context menu item to play the video on the linked page.
+ Nice for video lists; no need to access the detail page anymore.
+- Dreambox web interface access token support
+- Supports hundreds of video sites, see the `youtube-dl site support list`__.
+- Errors are displayed via the operating system's notification system
+
+__ http://rg3.github.io/youtube-dl/supportedsites.html
+
+
+Dependencies
+============
+You need to have the playVideoOnDreamboxProxy software running in your
+network.
+It will do the heavy lifting of extracting the video URL from the website
+and sending it to the dreambox.
+
+This browser extension only sends the current tab URL to this proxy service.
+
+In the extension settings, configure the proxy URL (it ends with ``play.php``).
+
+
+License
+=======
+``playVideoOnDreambox`` is licensed under the `GPL v3`__ or later.
+
+__ http://www.gnu.org/licenses/gpl.html
+
+
+Homepage
+========
+Web site
+ http://cweiske.de/playVideoOnDreambox.htm#firefox
+Source code
+ http://git.cweiske.de/playVideoOnDreambox.git
+
+ Mirror: https://github.com/cweiske/playVideoOnDreambox
+Firefox Add-ons site
+ https://addons.mozilla.org/de/firefox/addon/play-video-on-dreambox/
+Dreambox forum thread
+ http://www.dream-multimedia-tv.de/board/index.php?page=Thread&threadID=20224
+
+
+Author
+======
--- /dev/null
+#!/bin/sh
+set -e
+
+version=$(jq -r .version < src/manifest.json)
+
+filename="dist/playVideoOnDreambox-browser-$version.zip"
+test -d dist || mkdir dist
+
+if [ -f "$filename" ]; then
+ echo "File exists already: $filename" >&2
+ exit 10
+fi
+
+cd src
+zip -r "../$filename" *
+
+echo "File created: $filename"
--- /dev/null
+function handleToolbarPlay()
+{
+ browser.tabs.query({currentWindow: true, active: true}).then(
+ function (tabs) {
+ playUrl(tabs.shift().url);
+ }
+ );
+}
+
+function handleMenuClick(event)
+{
+ if ('mediaType' in event && event.mediaType == "video") {
+ playUrl(event.srcUrl);
+ } else if ('linkUrl' in event) {
+ playUrl(event.linkUrl);
+ } else {
+ console.error('No idea what to play here', event);
+ }
+}
+
+function playUrl(url)
+{
+ browser.browserAction.setBadgeText({text: '⧗'});
+ browser.browserAction.setBadgeTextColor({color: 'white'});
+ browser.browserAction.setBadgeBackgroundColor({color: 'orange'});
+
+ browser.storage.sync.get('proxyUrl').then((res) => {
+ var proxyUrl = res.proxyUrl;
+ console.log(url, proxyUrl);
+
+ fetch(
+ proxyUrl,
+ {
+ method: 'POST',
+ headers: {
+ 'Content-Type': 'text/plain'
+ },
+ //mode: 'no-cors',
+ body: url
+ }
+ ).then(function (response) {
+ console.log(response.ok);
+ if (response.ok) {
+ videoPlayOk(response);
+ } else {
+ videoPlayError(response);
+ }
+ }).catch(function (error) {
+ //e.g. Network error (when no network available)
+ showError(error.message);
+ });
+ });
+}
+
+function videoPlayOk(response)
+{
+ browser.notifications.create(
+ 'dreambox-playing',
+ {
+ type: 'basic',
+ title: 'Play video on Dreambox',
+ message: 'Video is playing now',
+ iconUrl: 'icon.png'
+ }
+ );
+
+ browser.browserAction.setBadgeText({text: '🗸'});
+ browser.browserAction.setBadgeTextColor({color: 'white'});
+ browser.browserAction.setBadgeBackgroundColor({color: 'green'});
+ setBadgeRemovalTimeout();
+}
+
+function videoPlayError(response)
+{
+ response.text().then(function (text) {
+ showError(text);
+ });
+}
+
+function showError(message)
+{
+ console.log("Play error: ", message);
+
+ browser.notifications.create(
+ 'dreambox-error',
+ {
+ type: 'basic',
+ title: 'Error playing video',
+ message: message,
+ iconUrl: 'icon.png'
+ }
+ );
+
+ browser.browserAction.setBadgeText({text: 'x'});
+ browser.browserAction.setBadgeTextColor({color: 'white'});
+ browser.browserAction.setBadgeBackgroundColor({color: 'red'});
+ setBadgeRemovalTimeout();
+}
+
+function setBadgeRemovalTimeout()
+{
+ setTimeout(
+ function () {
+ browser.browserAction.setBadgeText({text:""});
+ },
+ 5000
+ );
+}
+
+//toolbar button
+browser.browserAction.onClicked.addListener(handleToolbarPlay);
+
+//context menu
+browser.menus.create({
+ id: "play-video-on-dreambox-link",
+ title: "Play linked video on dreambox",
+ contexts: ["link"],
+ onclick: handleMenuClick,
+ icons: {
+ "16": "icon.png",
+ "32": "icon.png",
+ }
+});
+browser.menus.create({
+ id: "play-video-on-dreambox-video",
+ title: "Play this video on dreambox",
+ contexts: ["video"],
+ onclick: handleMenuClick,
+ icons: {
+ "16": "icon.png",
+ "32": "icon.png",
+ }
+});
--- /dev/null
+{
+ "manifest_version": 2,
+ "name": "playVideoOnDreambox",
+ "version": "0.6.0",
+ "description": "Play videos from websites on your Dreambox satellite receiver",
+ "homepage_url": "https://cweiske.de/playVideoOnDreambox.htm#firefox",
+ "author": "Christian Weiske",
+ "icons": {
+ "32": "icon.png"
+ },
+ "permissions": [
+ "activeTab",
+ "menus",
+ "notifications",
+ "storage"
+ ],
+ "browser_action": {
+ "default_icon": "icon.png",
+ "default_title": "Play video on Dreambox"
+ },
+ "background": {
+ "scripts": ["background-script.js"]
+ },
+ "options_ui": {
+ "page": "options.html",
+ "browser_style": true,
+ "chrome_style": true
+ },
+ "browser_specific_settings": {
+ "gecko": {
+ "id": "@playvideoondreambox"
+ }
+ }
+}
--- /dev/null
+<!DOCTYPE html>
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <meta charset="utf-8"/>
+ </head>
+ <body>
+ <form>
+ <label>playVideoOnDreambox<strong>Proxy</strong> URL</label>
+ <input type="url" id="proxyUrl" placeholder="http://.../play.php"/>
+ <button type="submit">Save</button>
+ <p>
+ You need to have the
+ <a href="https://cweiske.de/playVideoOnDreambox.htm#proxy">proxy application</a>
+ running on a server in your network.
+ </p>
+ </form>
+ <script src="options.js" type="text/javascript"></script>
+ </body>
+</html>
--- /dev/null
+function saveOptions(e)
+{
+ browser.storage.sync.set(
+ {
+ proxyUrl: document.querySelector("#proxyUrl").value
+ }
+ );
+ e.preventDefault();
+}
+
+function restoreOptions()
+{
+ var gettingItem = browser.storage.sync.get('proxyUrl');
+ gettingItem.then((res) => {
+ document.querySelector("#proxyUrl").value = res.proxyUrl || null;
+ });
+}
+
+document.addEventListener('DOMContentLoaded', restoreOptions);
+document.querySelector('form').addEventListener('submit', saveOptions);