v1.5
This commit is contained in:
parent
da85f9ea90
commit
7e261eb367
|
|
@ -13,7 +13,7 @@ chrome.runtime.onInstalled.addListener(function () {
|
|||
});
|
||||
});
|
||||
|
||||
function sendVideoUrlToMetube(videoUrl, metubeUrl, callback) {
|
||||
function sendVideoUrlToMetube(videoUrl, metubeUrl, format, callback) {
|
||||
console.log("Sending videoUrl=" + videoUrl + " to metubeUrl=" + metubeUrl);
|
||||
|
||||
if (typeof callback !== 'function') {
|
||||
|
|
@ -29,6 +29,7 @@ function sendVideoUrlToMetube(videoUrl, metubeUrl, callback) {
|
|||
},
|
||||
body: JSON.stringify({
|
||||
"quality": "best",
|
||||
"format": format,
|
||||
"url": videoUrl
|
||||
})
|
||||
})
|
||||
|
|
@ -42,7 +43,7 @@ function sendVideoUrlToMetube(videoUrl, metubeUrl, callback) {
|
|||
}
|
||||
|
||||
chrome.contextMenus.onClicked.addListener(function (item, tab) {
|
||||
chrome.storage.sync.get(['metube', 'contextMenuClickBehavior'], function (data) {
|
||||
chrome.storage.sync.get(['metube', 'contextMenuClickBehavior', 'defaultFormat'], function (data) {
|
||||
if (data === undefined || !data.hasOwnProperty('metube') || data.metube === "") {
|
||||
openTab(chrome.runtime.getURL('options.html'), tab);
|
||||
return
|
||||
|
|
@ -50,7 +51,7 @@ chrome.contextMenus.onClicked.addListener(function (item, tab) {
|
|||
|
||||
let needToSwitch = (data.contextMenuClickBehavior === 'context-menu-send-current-url-and-switch');
|
||||
|
||||
sendVideoUrlToMetube(item.linkUrl, data.metube, function () {
|
||||
sendVideoUrlToMetube(item.linkUrl, data.metube, data.defaultFormat, function () {
|
||||
if (needToSwitch) {
|
||||
openTab(data.metube, tab);
|
||||
}
|
||||
|
|
@ -59,7 +60,7 @@ chrome.contextMenus.onClicked.addListener(function (item, tab) {
|
|||
});
|
||||
|
||||
chrome.action.onClicked.addListener(function (tab) {
|
||||
chrome.storage.sync.get(['metube', 'clickBehavior'], function (data) {
|
||||
chrome.storage.sync.get(['metube', 'clickBehavior', 'defaultFormat'], function (data) {
|
||||
if (data === undefined || !data.hasOwnProperty('metube') || data.metube === "") {
|
||||
openTab(chrome.runtime.getURL('options.html'), tab);
|
||||
return
|
||||
|
|
@ -78,7 +79,7 @@ chrome.action.onClicked.addListener(function (tab) {
|
|||
}, function (tabs) {
|
||||
// use this tab to get the youtube video URL
|
||||
let videoUrl = tabs[0].url;
|
||||
sendVideoUrlToMetube(videoUrl, data.metube, function () {
|
||||
sendVideoUrlToMetube(videoUrl, data.metube, data.defaultFormat, function () {
|
||||
if (!needToSwitch) {
|
||||
openTab(data.metube, tab);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "MeTube Downloader",
|
||||
"description": "Use the context menu to send video into MeTube application",
|
||||
"version": "1.4",
|
||||
"version": "1.5",
|
||||
"manifest_version": 3,
|
||||
"permissions": ["contextMenus", "storage", "tabs"],
|
||||
"background": {
|
||||
|
|
|
|||
|
|
@ -32,7 +32,18 @@
|
|||
<form id="form">
|
||||
<h3>Settings</h3>
|
||||
<label for="metube">Url of MeTube</label><input type="url" placeholder="http://0.0.0.0:8081/" name="metube" id="metube">
|
||||
<br>
|
||||
<br><br>
|
||||
<label for="default_format">Video format:</label>
|
||||
|
||||
<select name="default_format" id="default_format">
|
||||
<option value="any">Any</option>
|
||||
<option value="mp4">MP4</option>
|
||||
<option value="m4a">M4A</option>
|
||||
<option value="mp3">MP3</option>
|
||||
<option value="opus">OPUS</option>
|
||||
<option value="wav">WAV</option>
|
||||
<option value="thumbnail">Thumbnail</option>
|
||||
</select>
|
||||
|
||||
<h4>When you left-click on the extension icon, you'd like it to:</h4>
|
||||
<input type="radio" name="click-behavior" id="go-to-metube" value="go-to-metube"><label for="go-to-metube">Go to MeTube URL</label><br>
|
||||
|
|
|
|||
|
|
@ -8,12 +8,14 @@ async function saveOptions() {
|
|||
let sites = document.getElementById("additional").value;
|
||||
let clickBehavior = document.querySelector('input[name="click-behavior"]:checked').value;
|
||||
let contextMenuClickBehavior = document.querySelector('input[name="context-menu-click-behavior"]:checked').value;
|
||||
let defaultFormat = document.getElementById('default_format').value
|
||||
|
||||
chrome.storage.sync.set({
|
||||
"metube": url,
|
||||
"sites": sites,
|
||||
"clickBehavior": clickBehavior,
|
||||
"contextMenuClickBehavior": contextMenuClickBehavior
|
||||
"contextMenuClickBehavior": contextMenuClickBehavior,
|
||||
"defaultFormat": defaultFormat,
|
||||
}, function () {
|
||||
document.getElementById("saved").classList.remove('hidden');
|
||||
|
||||
|
|
@ -50,7 +52,8 @@ async function restoreOptions() {
|
|||
'metube',
|
||||
'sites',
|
||||
'clickBehavior',
|
||||
'contextMenuClickBehavior'
|
||||
'contextMenuClickBehavior',
|
||||
'defaultFormat'
|
||||
], function (data) {
|
||||
if (data.metube !== undefined) {
|
||||
document.getElementById("metube").value = data.metube;
|
||||
|
|
@ -67,6 +70,10 @@ async function restoreOptions() {
|
|||
if (data.contextMenuClickBehavior !== undefined) {
|
||||
document.getElementById(data.contextMenuClickBehavior).checked = true;
|
||||
}
|
||||
|
||||
if (data.defaultFormat !== undefined) {
|
||||
document.getElementById('default_format').value = data.defaultFormat;
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue