Created
September 20, 2018 03:24
-
-
Save AlbinoDrought/5874e6ec3b506118910f3ed427b54771 to your computer and use it in GitHub Desktop.
Send links or pages to youtube-dl-web-ui
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"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