Cleaned up context menu and made download button in popup work
This commit is contained in:
@@ -1,25 +1,58 @@
|
||||
function Queue(info) {
|
||||
function QueueDownloadByInfo(info, mode, quality) {
|
||||
|
||||
// Select either the current page location, or the target of a href (if the user clicked on one)
|
||||
urlToDownload = typeof(info.linkUrl) != 'undefined' ? info.linkUrl : info.pageUrl;
|
||||
QueueDownload(
|
||||
urlToDownload = typeof(info.linkUrl) != 'undefined' ? info.linkUrl : info.pageUrl,
|
||||
mode,
|
||||
quality
|
||||
); // <- Defined in queueDwonload.js
|
||||
|
||||
axios.post("http://tub.io/api", {
|
||||
request: "queue_download",
|
||||
video_url: urlToDownload,
|
||||
mode: "video",
|
||||
quality: "best"
|
||||
}).then(function(response){
|
||||
console.log("Queued successfully...");
|
||||
}).catch(function(response){
|
||||
console.log("Something went wrong...");
|
||||
console.log(response);
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
// Create main context menu entry
|
||||
chrome.contextMenus.create({
|
||||
"title" : "Queue in Tubio",
|
||||
"contexts": ["all"],
|
||||
"type" : "normal",
|
||||
"onclick" : Queue
|
||||
title: "Tubio",
|
||||
contexts:["all"],
|
||||
id: "tubio-parent-contextmenu-entry",
|
||||
});
|
||||
|
||||
// Automate creating a lot of entries
|
||||
function CreateContextMenuOption(optionName, callback) {
|
||||
chrome.contextMenus.create({
|
||||
title: optionName,
|
||||
contexts: ["all"],
|
||||
type: "normal",
|
||||
parentId: "tubio-parent-contextmenu-entry",
|
||||
onclick: callback
|
||||
});
|
||||
}
|
||||
|
||||
// Create all download methods
|
||||
CreateContextMenuOption("Download Video - Best", function(info) {
|
||||
QueueDownloadByInfo(info, "video", "best");
|
||||
});
|
||||
CreateContextMenuOption("Download Video - 1440p", function(info) {
|
||||
QueueDownloadByInfo(info, "video", "1440p");
|
||||
});
|
||||
CreateContextMenuOption("Download Video - 1080p", function(info) {
|
||||
QueueDownloadByInfo(info, "video", "1080p");
|
||||
});
|
||||
CreateContextMenuOption("Download Video - 720p", function(info) {
|
||||
QueueDownloadByInfo(info, "video", "720p");
|
||||
});
|
||||
CreateContextMenuOption("Download Video - 480p", function(info) {
|
||||
QueueDownloadByInfo(info, "video", "480p");
|
||||
});
|
||||
CreateContextMenuOption("Download Video - 360p", function(info) {
|
||||
QueueDownloadByInfo(info, "video", "360p");
|
||||
});
|
||||
CreateContextMenuOption("Download Video - 240p", function(info) {
|
||||
QueueDownloadByInfo(info, "video", "240p");
|
||||
});
|
||||
CreateContextMenuOption("Download Video - 144p", function(info) {
|
||||
QueueDownloadByInfo(info, "video", "144p");
|
||||
});
|
||||
CreateContextMenuOption("Download Audio", function(info) {
|
||||
QueueDownloadByInfo(info, "audio", "best"); // <- Quality is ignored when downloading audio only
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user