Skip to content

Instantly share code, notes, and snippets.

@AlbinoDrought
Created September 20, 2018 03:24
Show Gist options
  • Save AlbinoDrought/5874e6ec3b506118910f3ed427b54771 to your computer and use it in GitHub Desktop.
Save AlbinoDrought/5874e6ec3b506118910f3ed427b54771 to your computer and use it in GitHub Desktop.
Send links or pages to youtube-dl-web-ui
browser.contextMenus.create({
id: "send-to-rippy",
title: "Send to Rippy",
contexts: ["all"],
});
browser.contextMenus.onClicked.addListener((info, tab) => {
if (info.menuItemId !== "send-to-rippy") {
return;
}
const url = info.linkUrl || tab.url;
fetch('http://rippy.internal.albinodrought.com/task', {
method: 'post',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
},
body: JSON.stringify({
url: url,
ydl_opts: {},
}),
}).then(function (response) {
return response.json();
}).then(function (data) {
// data.status maybe = success
// data.tid = something (task id?)
browser.tabs.create({
url: 'http://rippy.internal.albinodrought.com/',
});
}).catch(console.error);
});
{
"manifest_version": 2,
"name": "Send to Rippy",
"description": "Add a context menu option to send things to Rippy.",
"version": "1.0",
"homepage_url": "https://github.com/AlbinoDrought",
"applications": {
"gecko": {
"id": "rippy-ext@albinodrought.com",
"strict_min_version": "42.0"
}
},
"background": {
"scripts": [
"background.js"
]
},
"permissions": [
"activeTab",
"contextMenus",
"notifications",
"<all_urls>"
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment