├── .gitignore ├── src ├── icon.png ├── options.js ├── options.html ├── manifest.json └── background-script.js └── README.rst /.gitignore: -------------------------------------------------------------------------------- 1 | /node_modules/ 2 | /dist/ 3 | /package-lock.json 4 | -------------------------------------------------------------------------------- /src/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cweiske/playVideoOnDreambox/master/src/icon.png -------------------------------------------------------------------------------- /src/options.js: -------------------------------------------------------------------------------- 1 | function saveOptions(e) 2 | { 3 | browser.storage.sync.set( 4 | { 5 | proxyUrl: document.querySelector("#proxyUrl").value 6 | } 7 | ); 8 | e.preventDefault(); 9 | } 10 | 11 | function restoreOptions() 12 | { 13 | var gettingItem = browser.storage.sync.get('proxyUrl'); 14 | gettingItem.then((res) => { 15 | document.querySelector("#proxyUrl").value = res.proxyUrl || null; 16 | }); 17 | } 18 | 19 | document.addEventListener('DOMContentLoaded', restoreOptions); 20 | document.querySelector('form').addEventListener('submit', saveOptions); 21 | -------------------------------------------------------------------------------- /src/options.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 | 7 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /src/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "manifest_version": 2, 3 | "name": "playVideoOnDreambox", 4 | "version": "0.6.0", 5 | "description": "Play videos from websites on your Dreambox satellite receiver", 6 | "homepage_url": "https://cweiske.de/playVideoOnDreambox.htm#firefox", 7 | "author": "Christian Weiske", 8 | "icons": { 9 | "32": "icon.png" 10 | }, 11 | "permissions": [ 12 | "activeTab", 13 | "menus", 14 | "notifications", 15 | "storage" 16 | ], 17 | "browser_action": { 18 | "default_icon": "icon.png", 19 | "default_title": "Play video on Dreambox" 20 | }, 21 | "background": { 22 | "scripts": ["background-script.js"] 23 | }, 24 | "options_ui": { 25 | "page": "options.html", 26 | "browser_style": true, 27 | "chrome_style": true 28 | }, 29 | "browser_specific_settings": { 30 | "gecko": { 31 | "id": "@playvideoondreambox" 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /README.rst: -------------------------------------------------------------------------------- 1 | ************************************* 2 | playVideoOnDreambox Firefox extension 3 | ************************************* 4 | 5 | Firefox__ browser addon (extension) that adds a "Play on Dreambox" button to the 6 | toolbar. 7 | Pressing it plays the video of the current tab on your Dreambox__ satellite 8 | receiver. 9 | 10 | Works fine with a Dreambox `DM7080 HD`__. 11 | 12 | You can also right-click a link to a video page and select 13 | "Play linked video on Dreambox". 14 | That way you don't even need to open video detail pages. 15 | 16 | __ https://www.mozilla.org/firefox 17 | __ http://www.dream-multimedia-tv.de/products 18 | __ http://www.dream-multimedia-tv.de/dm7080-hd 19 | 20 | .. contents:: 21 | 22 | 23 | Features 24 | ======== 25 | - Toolbar button to play the video on the current page 26 | - Context menu item to play the video on the linked page. 27 | Nice for video lists; no need to access the detail page anymore. 28 | - Dreambox web interface access token support 29 | - Supports hundreds of video sites, see the `youtube-dl site support list`__. 30 | - Errors are displayed via the operating system's notification system 31 | 32 | __ http://rg3.github.io/youtube-dl/supportedsites.html 33 | 34 | 35 | Dependencies 36 | ============ 37 | You need to have the playVideoOnDreamboxProxy software running in your 38 | network. 39 | It will do the heavy lifting of extracting the video URL from the website 40 | and sending it to the dreambox. 41 | 42 | This browser extension only sends the current tab URL to this proxy service. 43 | 44 | In the extension settings, configure the proxy URL (it ends with ``play.php``). 45 | 46 | 47 | License 48 | ======= 49 | ``playVideoOnDreambox`` is licensed under the `GPL v3`__ or later. 50 | 51 | __ http://www.gnu.org/licenses/gpl.html 52 | 53 | 54 | Homepage 55 | ======== 56 | Web site 57 | http://cweiske.de/playVideoOnDreambox.htm#firefox 58 | Source code 59 | http://git.cweiske.de/playVideoOnDreambox.git 60 | 61 | Mirror: https://github.com/cweiske/playVideoOnDreambox 62 | Firefox Add-ons site 63 | https://addons.mozilla.org/de/firefox/addon/play-video-on-dreambox/ 64 | Dreambox forum thread 65 | http://www.dream-multimedia-tv.de/board/index.php?page=Thread&threadID=20224 66 | 67 | 68 | Author 69 | ====== 70 | Written by Christian Weiske, cweiske@cweiske.de 71 | -------------------------------------------------------------------------------- /src/background-script.js: -------------------------------------------------------------------------------- 1 | function handleToolbarPlay() 2 | { 3 | browser.tabs.query({currentWindow: true, active: true}).then( 4 | function (tabs) { 5 | playUrl(tabs.shift().url); 6 | } 7 | ); 8 | } 9 | 10 | function handleMenuClick(event) 11 | { 12 | if ('mediaType' in event && event.mediaType == "video") { 13 | playUrl(event.srcUrl); 14 | } else if ('linkUrl' in event) { 15 | playUrl(event.linkUrl); 16 | } else { 17 | console.error('No idea what to play here', event); 18 | } 19 | } 20 | 21 | function playUrl(url) 22 | { 23 | browser.browserAction.setBadgeText({text: '⧗'}); 24 | browser.browserAction.setBadgeTextColor({color: 'white'}); 25 | browser.browserAction.setBadgeBackgroundColor({color: 'orange'}); 26 | 27 | browser.storage.sync.get('proxyUrl').then((res) => { 28 | var proxyUrl = res.proxyUrl; 29 | console.log(url, proxyUrl); 30 | 31 | fetch( 32 | proxyUrl, 33 | { 34 | method: 'POST', 35 | headers: { 36 | 'Content-Type': 'text/plain' 37 | }, 38 | //mode: 'no-cors', 39 | body: url 40 | } 41 | ).then(function (response) { 42 | console.log(response.ok); 43 | if (response.ok) { 44 | videoPlayOk(response); 45 | } else { 46 | videoPlayError(response); 47 | } 48 | }).catch(function (error) { 49 | //e.g. Network error (when no network available) 50 | showError(error.message); 51 | }); 52 | }); 53 | } 54 | 55 | function videoPlayOk(response) 56 | { 57 | browser.notifications.create( 58 | 'dreambox-playing', 59 | { 60 | type: 'basic', 61 | title: 'Play video on Dreambox', 62 | message: 'Video is playing now', 63 | iconUrl: 'icon.png' 64 | } 65 | ); 66 | 67 | browser.browserAction.setBadgeText({text: '🗸'}); 68 | browser.browserAction.setBadgeTextColor({color: 'white'}); 69 | browser.browserAction.setBadgeBackgroundColor({color: 'green'}); 70 | setBadgeRemovalTimeout(); 71 | } 72 | 73 | function videoPlayError(response) 74 | { 75 | response.text().then(function (text) { 76 | showError(text); 77 | }); 78 | } 79 | 80 | function showError(message) 81 | { 82 | console.log("Play error: ", message); 83 | 84 | browser.notifications.create( 85 | 'dreambox-error', 86 | { 87 | type: 'basic', 88 | title: 'Error playing video', 89 | message: message, 90 | iconUrl: 'icon.png' 91 | } 92 | ); 93 | 94 | browser.browserAction.setBadgeText({text: 'x'}); 95 | browser.browserAction.setBadgeTextColor({color: 'white'}); 96 | browser.browserAction.setBadgeBackgroundColor({color: 'red'}); 97 | setBadgeRemovalTimeout(); 98 | } 99 | 100 | function setBadgeRemovalTimeout() 101 | { 102 | setTimeout( 103 | function () { 104 | browser.browserAction.setBadgeText({text:""}); 105 | }, 106 | 5000 107 | ); 108 | } 109 | 110 | //toolbar button 111 | browser.browserAction.onClicked.addListener(handleToolbarPlay); 112 | 113 | //context menu 114 | browser.menus.create({ 115 | id: "play-video-on-dreambox-link", 116 | title: "Play linked video on dreambox", 117 | contexts: ["link"], 118 | onclick: handleMenuClick, 119 | icons: { 120 | "16": "icon.png", 121 | "32": "icon.png", 122 | } 123 | }); 124 | browser.menus.create({ 125 | id: "play-video-on-dreambox-video", 126 | title: "Play this video on dreambox", 127 | contexts: ["video"], 128 | onclick: handleMenuClick, 129 | icons: { 130 | "16": "icon.png", 131 | "32": "icon.png", 132 | } 133 | }); 134 | --------------------------------------------------------------------------------