Minor code refactor in sendVideoUrlToMetube function as per suggestion

This commit is contained in:
Akash Vacher 2022-10-07 09:02:43 -07:00
parent 87704abeca
commit 45b3eb289a
2 changed files with 18 additions and 1 deletions

View File

@ -39,7 +39,9 @@ function sendVideoUrlToMetube(videoUrl, metubeUrl, callback) {
}
}
}).then(function() {
typeof callback === 'function' && callback();
if (typeof callback === 'function'){
callback();
}
}).catch(function(e) {
console.log("Ran into an error :: ", e);
});
@ -63,6 +65,19 @@ chrome.contextMenus.onClicked.addListener(function(item, tab) {
});
});
async function getCurrentTabUrl() {
chrome.tabs.query({
active: true,
lastFocusedWindow: true
}, function(tabs) {
// use this tab to get the youtube video URL
let videoUrl = tabs[0].url;
console.log("Got current tab URL", videoUrl);
return videoUrl;
});
}
chrome.action.onClicked.addListener(function(tab) {
chrome.storage.sync.get(['metube', 'clickBehavior'], function(data) {
if (data === undefined || !data.hasOwnProperty('metube') || data.metube === "") {

2
x Executable file
View File

@ -0,0 +1,2 @@
#!/bin/bash
./build.sh --force && cd /Users/avacher/code/hackday/opensource/metube-browser-extension/builds && unzip -o metube-browser-extension-1.3.zip -d metube-browser-extension-1.3; cd ~/code/hackday/opensource/metube-browser-extension