forked from woodruffw/ff2mpv
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathff2mpv.js
More file actions
25 lines (22 loc) · 691 Bytes
/
ff2mpv.js
File metadata and controls
25 lines (22 loc) · 691 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
function ff2mpv(url) {
browser.runtime.sendNativeMessage("ff2mpv", { url: url });
}
browser.contextMenus.create({
id: "ff2mpv",
title: "Play in MPV",
contexts: ["link", "image", "video", "audio", "selection"]
});
browser.contextMenus.onClicked.addListener((info, tab) => {
switch (info.menuItemId) {
case "ff2mpv":
/* These should be mutually exclusive, but,
if they aren't, this is a reasonable priority.
*/
url = info.linkUrl || info.srcUrl || info.selectionText;
if (url) ff2mpv(url);
break;
}
});
browser.browserAction.onClicked.addListener((tab) => {
ff2mpv(tab.url);
});