Compare commits
No commits in common. "55c3b548ca1e3bad497884da816940fd45410b44" and "46fd45bbaadac397dd85bab4f8b87c9a8e857f19" have entirely different histories.
55c3b548ca
...
46fd45bbaa
Binary file not shown.
Binary file not shown.
|
|
@ -11,12 +11,6 @@ chrome.runtime.onInstalled.addListener(function () {
|
||||||
],
|
],
|
||||||
contexts: ['link'],
|
contexts: ['link'],
|
||||||
});
|
});
|
||||||
|
|
||||||
chrome.contextMenus.create({
|
|
||||||
id: 'metube-page',
|
|
||||||
title: "Send page to MeTube",
|
|
||||||
contexts: ['page'],
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
function sendVideoUrlToMetube(videoUrl, metubeUrl, format, advancedSettings, callback) {
|
function sendVideoUrlToMetube(videoUrl, metubeUrl, format, advancedSettings, callback) {
|
||||||
|
|
@ -32,18 +26,15 @@ function sendVideoUrlToMetube(videoUrl, metubeUrl, format, advancedSettings, cal
|
||||||
let postData = {
|
let postData = {
|
||||||
"quality": "best",
|
"quality": "best",
|
||||||
"format": format,
|
"format": format,
|
||||||
"url": videoUrl,
|
"url": videoUrl
|
||||||
'auto_start': !advancedSettings['disable_auto_start'] ?? true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Object.keys(advancedSettings).forEach((key) => {
|
Object.keys(advancedSettings).forEach((key) => {
|
||||||
if (advancedSettings[key] && !['disable_auto_start'].includes(key) ) {
|
if (advancedSettings[key]) {
|
||||||
postData[key] = hostname.startsWith('www.') ? hostname.replace('www.', '') : hostname
|
postData[key] = hostname.startsWith('www.') ? hostname.replace('www.', '') : hostname
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
console.log(postData)
|
|
||||||
fetch(metubeUrl + "/add", {
|
fetch(metubeUrl + "/add", {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
|
|
@ -70,8 +61,7 @@ chrome.contextMenus.onClicked.addListener(function (item, tab) {
|
||||||
|
|
||||||
let needToSwitch = (data.contextMenuClickBehavior === 'context-menu-send-current-url-and-switch');
|
let needToSwitch = (data.contextMenuClickBehavior === 'context-menu-send-current-url-and-switch');
|
||||||
|
|
||||||
let videoUrl = item.linkUrl || item.pageUrl;
|
sendVideoUrlToMetube(item.linkUrl, data.metube, data.defaultFormat, data.advancedSettings, function () {
|
||||||
sendVideoUrlToMetube(videoUrl, data.metube, data.defaultFormat, data.advancedSettings, function () {
|
|
||||||
if (needToSwitch) {
|
if (needToSwitch) {
|
||||||
openTab(data.metube, tab);
|
openTab(data.metube, tab);
|
||||||
}
|
}
|
||||||
|
|
@ -100,7 +90,7 @@ chrome.action.onClicked.addListener(function (tab) {
|
||||||
// use this tab to get the youtube video URL
|
// use this tab to get the youtube video URL
|
||||||
let videoUrl = tabs[0].url;
|
let videoUrl = tabs[0].url;
|
||||||
sendVideoUrlToMetube(videoUrl, data.metube, data.defaultFormat, data.advancedSettings, function () {
|
sendVideoUrlToMetube(videoUrl, data.metube, data.defaultFormat, data.advancedSettings, function () {
|
||||||
if (needToSwitch) {
|
if (!needToSwitch) {
|
||||||
openTab(data.metube, tab);
|
openTab(data.metube, tab);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "MeTube Downloader",
|
"name": "MeTube Downloader",
|
||||||
"description": "Use the context menu to send video into MeTube application",
|
"description": "Use the context menu to send video into MeTube application",
|
||||||
"version": "1.7",
|
"version": "1.5",
|
||||||
"manifest_version": 3,
|
"manifest_version": 3,
|
||||||
"permissions": ["contextMenus", "storage", "tabs"],
|
"permissions": ["contextMenus", "storage", "tabs"],
|
||||||
"background": {
|
"background": {
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,6 @@
|
||||||
<div id="advanced_settings">
|
<div id="advanced_settings">
|
||||||
<input type="checkbox" name="folder" id="folder" value="true"><label for="folder">Use subfolder based on the Hostname of the URL</label><br>
|
<input type="checkbox" name="folder" id="folder" value="true"><label for="folder">Use subfolder based on the Hostname of the URL</label><br>
|
||||||
<input type="checkbox" name="custom_name_prefix" id="custom_name_prefix" value="true"><label for="custom_name_prefix">Use name-prefix based on the Hostname of the URL</label><br>
|
<input type="checkbox" name="custom_name_prefix" id="custom_name_prefix" value="true"><label for="custom_name_prefix">Use name-prefix based on the Hostname of the URL</label><br>
|
||||||
<input type="checkbox" name="disable_auto_start" id="disable_auto_start" value="true"><label for="disable_auto_start">Disable auto start of Downloads</label><br>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<h3>Additional sites</h3>
|
<h3>Additional sites</h3>
|
||||||
|
|
|
||||||
|
|
@ -12,15 +12,13 @@ async function saveOptions() {
|
||||||
|
|
||||||
let advancedElements = document.querySelectorAll('#advanced_settings input');
|
let advancedElements = document.querySelectorAll('#advanced_settings input');
|
||||||
|
|
||||||
let advancedSettings = {
|
let advancedSettings = {};
|
||||||
'folder': false,
|
|
||||||
'custom_name_prefix': false,
|
|
||||||
'disable_auto_start': false
|
|
||||||
};
|
|
||||||
advancedElements.forEach((e) => {
|
advancedElements.forEach((e) => {
|
||||||
advancedSettings[e.name] = e.checked ? true : false
|
advancedSettings[e.name] = e.checked ? true : false
|
||||||
})
|
})
|
||||||
|
|
||||||
|
console.log(advancedSettings)
|
||||||
|
|
||||||
chrome.storage.sync.set({
|
chrome.storage.sync.set({
|
||||||
"metube": url,
|
"metube": url,
|
||||||
"sites": sites,
|
"sites": sites,
|
||||||
|
|
@ -41,7 +39,7 @@ async function saveOptions() {
|
||||||
// todo: fix it
|
// todo: fix it
|
||||||
// also need make function for check string
|
// also need make function for check string
|
||||||
// https://developer.chrome.com/docs/extensions/mv3/match_patterns/
|
// https://developer.chrome.com/docs/extensions/mv3/match_patterns/
|
||||||
if(!sites.length){
|
if(sites.length <= 1){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -57,18 +55,6 @@ async function saveOptions() {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
chrome.contextMenus.update(
|
|
||||||
'metube-page',
|
|
||||||
{
|
|
||||||
documentUrlPatterns: [
|
|
||||||
'https://www.youtube.com/*',
|
|
||||||
'https://m.youtube.com/*',
|
|
||||||
'https://youtu.be/*',
|
|
||||||
...sites
|
|
||||||
]
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function restoreOptions() {
|
async function restoreOptions() {
|
||||||
|
|
@ -102,6 +88,7 @@ async function restoreOptions() {
|
||||||
|
|
||||||
if (data.advancedSettings !== undefined) {
|
if (data.advancedSettings !== undefined) {
|
||||||
Object.keys(data.advancedSettings).forEach((key) => {
|
Object.keys(data.advancedSettings).forEach((key) => {
|
||||||
|
console.log(key)
|
||||||
document.getElementById(key).checked = data.advancedSettings[key];
|
document.getElementById(key).checked = data.advancedSettings[key];
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue