Added option for silently sending a video to MeTube via contextmenu (no tab switch)
The default behavior of sending a video to MeTube and switching to MeTube tab is still the default, but this new behavior is also added now in the extension options.
This commit is contained in:
parent
7a104e2e8c
commit
92a7c850ab
|
|
@ -46,14 +46,20 @@ function sendVideoUrlToMetube(videoUrl, metubeUrl, callback) {
|
||||||
}
|
}
|
||||||
|
|
||||||
chrome.contextMenus.onClicked.addListener(function(item, tab) {
|
chrome.contextMenus.onClicked.addListener(function(item, tab) {
|
||||||
chrome.storage.sync.get(['metube'], function(data) {
|
chrome.storage.sync.get(['metube', 'contextMenuClickBehavior'], function(data) {
|
||||||
if (data === undefined || !data.hasOwnProperty('metube') || data.metube === "") {
|
if (data === undefined || !data.hasOwnProperty('metube') || data.metube === "") {
|
||||||
openTab(chrome.runtime.getURL('options.html'), tab);
|
openTab(chrome.runtime.getURL('options.html'), tab);
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
sendVideoUrlToMetube(item.linkUrl, data.metube, function() {
|
if ( data.contextMenuClickBehavior == 'context-menu-send-current-url') {
|
||||||
openTab(data.metube, tab);
|
sendVideoUrlToMetube(item.linkUrl, data.metube);
|
||||||
});
|
} else if (data.contextMenuClickBehavior == 'context-menu-send-current-url-and-switch'){
|
||||||
|
sendVideoUrlToMetube(item.linkUrl, data.metube, function() {
|
||||||
|
openTab(data.metube, tab);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
console.log("Unknown contextMenuClickBehavior value: " + data.contextMenuClickBehavior);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -33,11 +33,17 @@
|
||||||
<h3>Settings</h3>
|
<h3>Settings</h3>
|
||||||
<label for="metube">Url of MeTube</label><input type="url" placeholder="http://0.0.0.0:8081/" name="metube" id="metube">
|
<label for="metube">Url of MeTube</label><input type="url" placeholder="http://0.0.0.0:8081/" name="metube" id="metube">
|
||||||
<br>
|
<br>
|
||||||
<h4>Left-click on extension icon behavior</h4>
|
|
||||||
|
<h4>When you left-click on the extension icon, you'd like it to:</h4>
|
||||||
<input type="radio" name="click-behavior" id="do-nothing" value="do-nothing"><label for="do-nothing">Do Nothing</label><br>
|
<input type="radio" name="click-behavior" id="do-nothing" value="do-nothing"><label for="do-nothing">Do Nothing</label><br>
|
||||||
<input type="radio" name="click-behavior" id="go-to-metube" value="go-to-metube" checked><label for="go-to-metube">Go to MeTube URL</label><br>
|
<input type="radio" name="click-behavior" id="go-to-metube" value="go-to-metube" checked><label for="go-to-metube">Go to MeTube URL</label><br>
|
||||||
<input type="radio" name="click-behavior" id="send-current-url" value="send-current-url"><label for="send-current-url">Send current tab URL to MeTube (no tab switch)</label><br>
|
<input type="radio" name="click-behavior" id="send-current-url" value="send-current-url"><label for="send-current-url">Send current tab URL to MeTube (no tab switch)</label><br>
|
||||||
<input type="radio" name="click-behavior" id="send-current-url-and-switch" value="send-current-url-and-switch"><label for="send-current-url-and-switch">Send current tab URL to MeTube and switch to MeTube</label><br>
|
<input type="radio" name="click-behavior" id="send-current-url-and-switch" value="send-current-url-and-switch"><label for="send-current-url-and-switch">Send current tab URL to MeTube and switch to MeTube</label><br>
|
||||||
|
|
||||||
|
<h4>When you right-click on video preview, you'd like it to:</h4>
|
||||||
|
<input type="radio" name="context-menu-click-behavior" id="context-menu-send-current-url" value="context-menu-send-current-url"><label for="context-menu-send-current-url">Send the video URL to MeTube (no tab switch)</label><br>
|
||||||
|
<input type="radio" name="context-menu-click-behavior" id="context-menu-send-current-url-and-switch" value="context-menu-send-current-url-and-switch" checked><label for="context-menu-send-current-url-and-switch">Send the video URL to MeTube and switch to MeTube</label><br>
|
||||||
|
|
||||||
<h3>Additional sites</h3>
|
<h3>Additional sites</h3>
|
||||||
<p>Youtube-dl support <a href="https://github.com/ytdl-org/youtube-dl/blob/master/docs/supportedsites.md" target="_blank">many another sites</a> except youtube. You can add mask url's of this sites in textfield bellow but it can affect performance and we have not tested them support</p>
|
<p>Youtube-dl support <a href="https://github.com/ytdl-org/youtube-dl/blob/master/docs/supportedsites.md" target="_blank">many another sites</a> except youtube. You can add mask url's of this sites in textfield bellow but it can affect performance and we have not tested them support</p>
|
||||||
<p><textarea name="additional" id="additional" placeholder="https://vimeo.com/*
|
<p><textarea name="additional" id="additional" placeholder="https://vimeo.com/*
|
||||||
|
|
|
||||||
|
|
@ -9,10 +9,13 @@ async function saveOptions() {
|
||||||
|
|
||||||
let clickBehavior = document.querySelector('input[name="click-behavior"]:checked').value;
|
let clickBehavior = document.querySelector('input[name="click-behavior"]:checked').value;
|
||||||
|
|
||||||
|
let contextMenuClickBehavior = document.querySelector('input[name="context-menu-click-behavior"]:checked').value;
|
||||||
|
|
||||||
chrome.storage.sync.set({
|
chrome.storage.sync.set({
|
||||||
"metube": url,
|
"metube": url,
|
||||||
"sites": sites,
|
"sites": sites,
|
||||||
"clickBehavior": clickBehavior
|
"clickBehavior": clickBehavior,
|
||||||
|
"contextMenuClickBehavior": contextMenuClickBehavior
|
||||||
}, function () {
|
}, function () {
|
||||||
document.getElementById("saved").classList.remove('hidden');
|
document.getElementById("saved").classList.remove('hidden');
|
||||||
|
|
||||||
|
|
@ -48,7 +51,8 @@ async function restoreOptions() {
|
||||||
chrome.storage.sync.get([
|
chrome.storage.sync.get([
|
||||||
'metube',
|
'metube',
|
||||||
'sites',
|
'sites',
|
||||||
'clickBehavior'
|
'clickBehavior',
|
||||||
|
'contextMenuClickBehavior'
|
||||||
], function (data) {
|
], function (data) {
|
||||||
if (data.metube != undefined) {
|
if (data.metube != undefined) {
|
||||||
document.getElementById("metube").value = data.metube;
|
document.getElementById("metube").value = data.metube;
|
||||||
|
|
@ -59,6 +63,7 @@ async function restoreOptions() {
|
||||||
}
|
}
|
||||||
|
|
||||||
document.getElementById(data.clickBehavior).checked = true;
|
document.getElementById(data.clickBehavior).checked = true;
|
||||||
|
document.getElementById(data.contextMenuClickBehavior).checked = true;
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue