Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
woodruffw committed Sep 30, 2017
0 parents commit f643cda
Show file tree
Hide file tree
Showing 12 changed files with 125 additions and 0 deletions.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2017 William Woodruff <william @ yossarian.net>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
ff2mpv
======

This is a Firefox addon for playing URLs in MPV.

Clicking the little icon in your toolbar will make MPV attempt to play the current URL.

If you want to play a specific URL on a page, right click it and click the "Play in MPV"
context button.

## Usage

First, install the addon from [AMO](https://addons.mozilla.org).

Then, copy `ff2mpv` (the Ruby script) to somewhere of your choice. Make sure it's executable.

Finally, copy `ff2mpv.json` (in this repository) into `~/.mozilla/native-messaging-hosts/`. Open
it in your editor, and change the `path` field to correspond to the path where you saved
the `ff2mpv` script.

After that, everything should work.

## License

The source code in this repository is licensed under the MIT license.

The icons in this repository are licensed by the MPV team under GNU LGPL, version 2.1.
10 changes: 10 additions & 0 deletions ff2mpv
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

require "json"

len = STDIN.read(4).unpack("L").first
url = JSON.parse STDIN.read(len)

pid = spawn "mpv", "--", url, in: :close, out: :close, err: :close
Process.detach pid
25 changes: 25 additions & 0 deletions ff2mpv.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
function ff2mpv(url) {
browser.runtime.sendNativeMessage("ff2mpv", url);
}

browser.menus.create({
id: "ff2mpv",
title: "Play in MPV",
contexts: ["link"],
icons: {
"16": "icons/icon_16x16.png",
"32": "icons/icon_32x32.png",
},
});

browser.menus.onClicked.addListener((info, tab) => {
switch (info.menuItemId) {
case "ff2mpv":
ff2mpv(info.linkUrl);
break;
}
});

browser.browserAction.onClicked.addListener((tab) => {
ff2mpv(tab.url);
});
7 changes: 7 additions & 0 deletions ff2mpv.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "ff2mpv",
"description": "ff2mpv's external manifest",
"path": "/home/william/scripts/ff2mpv",
"type": "stdio",
"allowed_extensions": ["[email protected]"]
}
Binary file added icons/icon_16x16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/icon_256x256.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/icon_32x32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/icon_48x48.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/icon_64x64.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 32 additions & 0 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"description": "Tries to play links in MPV",
"manifest_version": 2,
"name": "ff2mpv",
"version": "1.0",

"icons": {
"16": "icons/icon_16x16.png",
"32": "icons/icon_32x32.png",
"48": "icons/icon_48x48.png",
"64": "icons/icon_64x64.png",
"256": "icons/icon_256x256.png"
},

"browser_action": {
"default_icon": "icons/icon_48x48.png",
"default_title": "Play the current URL in MPV"
},

"applications": {
"gecko": {
"id": "[email protected]",
"strict_min_version": "50.0"
}
},

"background": {
"scripts": ["ff2mpv.js"]
},

"permissions": ["nativeMessaging", "contextMenus", "menus", "activeTab"]
}
3 changes: 3 additions & 0 deletions package.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash

zip ff2mpv.zip manifest.json ff2mpv.js icons/* LICENSE

0 comments on commit f643cda

Please sign in to comment.