Completed chrome extension

This commit is contained in:
Leonetienne 2021-03-13 18:56:08 +01:00
parent c10a3f40f2
commit 5f3012948c
6 changed files with 57 additions and 18 deletions

View File

@ -1,6 +1,6 @@
body { body {
width: 300px; width: 300px;
height: 300px; height: 310px;
margin: 0 !important; margin: 0 !important;
} }
body .bgmask { body .bgmask {

View File

@ -9,7 +9,17 @@ button {
transform 0.15s ease; transform 0.15s ease;
} }
button.small {
padding: 0.15em 1em;
}
button:hover { button:hover {
transform: scale(1.075);
color: #fff;
background-color: #5954a4;
}
button.special:hover {
/*background-color: #5954a4;*/ /*background-color: #5954a4;*/
color: #fff; color: #fff;
animation: color-cycle; animation: color-cycle;

View File

@ -1,6 +1,6 @@
* { * {
font-family: 'ZillaSlab' !important; font-family: 'ZillaSlab' !important;
color: #ddd; color: #dadada;
} }
p, p,

View File

@ -24,12 +24,14 @@
<div class="flex flex-col align-items-center"> <div class="flex flex-col align-items-center">
<!-- Download this - button --> <!-- Download this - button -->
<button id="button-download" title="Will download this pages URL as a video of highest quality."> <button class="special" id="button-download" title="Will download this pages URL as a video of highest quality.">
Download! Download!
</button> </button>
<!-- Tubio config form -->
<label for="tubio-address" style="margin-top: 3em;">Where can i reach tubio?</label> <label for="tubio-address" style="margin-top: 3em;">Where can i reach tubio?</label>
<input type="text" id="tubio-address" class="text-center" /> <input type="text" id="tubio-address" class="text-center" />
<button class="small" id="button-save-settings" style="margin-top: 0.5em;">Save settings</button>
</div> </div>
</div> </div>

View File

@ -20,3 +20,13 @@ $("#button-download").click(function() {
return; return;
}); });
chrome.storage.local.get(['tubio_address'], function(result) {
$("#tubio-address").val(result.tubio_address);
});
$("#button-save-settings").click(function() {
chrome.storage.local.set({
tubio_address: $("#tubio-address").val()
});
});

View File

@ -1,21 +1,38 @@
function QueueDownload(url, mode, quality, callback) { function QueueDownload(url, mode, quality, callback) {
console.log("Queuing '" + url + "'..."); console.log("Queueing '" + url + "'...");
// Fetch tubio address
chrome.storage.local.get(['tubio_address'], function(result) {
if ((typeof(result.tubio_address) == 'undefined') ||
(result.tubio_address.length == 0)) {
alert("Please first set an address to reach Tubio at in the extensions settings! (Click on the extensions icon in the toolbar).");
return;
} else {
tubioUrl = result.tubio_address;
if (tubioUrl[tubioUrl.length-1] != '/') { // Has the user not appended a /?
tubioUrl += '/';
}
axios.post(tubioUrl + "api", {
request: "queue_download",
video_url: url,
mode: mode,
quality: quality
}).then(function(response){
console.log("Queued successfully...");
if (typeof(callback) != 'undefined') callback(true, response);
}).catch(function(response){
console.log("Something went wrong...");
console.log(response);
if (typeof(callback) != 'undefined') callback(false, response);
});
}
});
axios.post("http://tub.io/api", {
request: "queue_download",
video_url: url,
mode: mode,
quality: quality
}).then(function(response){
console.log("Queued successfully...");
if (typeof(callback) != 'undefined') callback(true, response);
}).catch(function(response){
console.log("Something went wrong...");
console.log(response);
if (typeof(callback) != 'undefined') callback(false, response);
});
return; return;
} }