diff --git a/goodies/chrome-extension/background.js b/goodies/chrome-extension/background.js index a9fb07f..baa5a25 100644 --- a/goodies/chrome-extension/background.js +++ b/goodies/chrome-extension/background.js @@ -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 +}); diff --git a/goodies/chrome-extension/manifest.json b/goodies/chrome-extension/manifest.json index c843e19..9066b66 100644 --- a/goodies/chrome-extension/manifest.json +++ b/goodies/chrome-extension/manifest.json @@ -17,6 +17,8 @@ "background", "contextMenus", "webRequest", + "windows", + "tabs", "storage", "*://*/*" ], @@ -24,22 +26,8 @@ "background": { "scripts": [ "lib/axios.js", + "queueDownload.js", "background.js" ] - }, - - "content_scripts": [ - { - "run_at": "document_end", - "js": [ - "lib/jquery-3.5.1.min.js", - "lib/axios.js" - ], - "css": [ - ], - "matches": [ - "*://*/*" - ] - } - ] + } } diff --git a/goodies/chrome-extension/popup/css/button.css b/goodies/chrome-extension/popup/css/button.css index 219c8bb..1b32782 100644 --- a/goodies/chrome-extension/popup/css/button.css +++ b/goodies/chrome-extension/popup/css/button.css @@ -17,6 +17,10 @@ button:hover { animation-iteration-count: infinite; } +button.lock { + visibility: hidden; +} + @keyframes color-cycle { 0% {background-color: #ff6666; transform: scale(1.075);} 16.67% {background-color: #c966ff;} diff --git a/goodies/chrome-extension/popup/index.html b/goodies/chrome-extension/popup/index.html index 64facdc..9efe69e 100644 --- a/goodies/chrome-extension/popup/index.html +++ b/goodies/chrome-extension/popup/index.html @@ -17,18 +17,26 @@
-