Respect One-Click Mode in context menu and keyboard shortcut

This commit is contained in:
nanocortex committed 2026-08-12 21:52:35 +02:00
1 parent 7013d548b2
commit 2a662c77ea
4 files changed
+31 -28

No files matched your search

+5
View File
@@ -1,5 +1,10 @@
# Changelog
## Unreleased
- The context menu and keyboard shortcut no longer send the download before you can react. With One-Click Mode disabled they now open the popup pre-filled with the target URL, so quality, folder and other options can be adjusted first ([#18](https://github.com/nanocortex/metube-firefox-addon/issues/18)).
- With One-Click Mode enabled, all four entry points queue the download immediately without opening the popup.
- Right-clicking a link now carries that link's URL into the popup instead of the URL of the page you are on.
## 1.8.1 - 2026-08-12
- Default folder and custom name prefix now support variables: `%HOSTNAME%`, `%DOMAIN%`, `%DATE%`, `%YEAR%`, `%MONTH%`, `%DAY%`. For example, a folder of `videos/%DOMAIN%` files a YouTube download under `videos/youtube.com`, so downloads can be categorized by site automatically ([#26](https://github.com/nanocortex/metube-firefox-addon/issues/26)).
- Variables are resolved against the URL actually being sent, so right-clicking a link uses that link's host rather than the host of the page you're on.
+3 -1
View File
@@ -43,6 +43,8 @@ See the [CHANGELOG](CHANGELOG.md) for version history and release notes.
- Right-click on a video link and select "Send to MeTube"
- Right-click on the page itself and select "Send page to MeTube"
All four methods behave the same way, controlled by **One-Click Mode**. When it is disabled (the default), the popup opens pre-filled with the target URL so you can adjust quality, folder or any other option before sending. When it is enabled, the download is queued immediately without opening the popup.
### Keyboard Shortcuts
The extension supports the following keyboard shortcut:
@@ -114,7 +116,7 @@ The **Default Folder** and **Custom Name Prefix** settings accept variables that
| **Show Context Menu on Links** | Show "Send to MeTube" when right-clicking links | `true` |
| **Show Context Menu on Page** | Show "Send page to MeTube" when right-clicking the page | `true` |
| **Auto Start** | Automatically start downloads when ready | `true` |
| **One-Click Mode** | Send current page to MeTube with one click | `false` |
| **One-Click Mode** | Queue downloads immediately instead of opening the popup. Applies to the toolbar icon, the keyboard shortcut and both context menu entries | `false` |
| **Strict Playlist Mode** | Only download playlists when URL explicitly points to one (prevents downloading YouTube Mixes when you only want the current video) | `false` |
| **Send Custom Headers** | Enable inclusion of custom headers when queueing | `false` |
| **Custom Headers** | Specify custom header names and values for authentication or other purposes | `[]` (empty) |
+22 -21
View File
@@ -247,30 +247,35 @@ async function sendToMeTube(itemUrl, options) {
}
}
function triggerSendWithLoading(url) {
setTimeout(async () => {
try {
await browser.runtime.sendMessage({ command: 'showLoading' });
} catch (error) {
console.error("Failed to send showLoading message:", error);
}
async function openPopupWithUrl(url) {
browser.browserAction.setPopup({
popup: `popup/popup.html?url=${encodeURIComponent(url)}`
});
const options = await getDefaultSendOptions();
await sendToMeTube(url, options);
}, 100);
try {
await browser.browserAction.openPopup();
} catch (error) {
console.error("Failed to open popup:", error);
} finally {
// Only affects later openings; the popup opened above keeps its url.
browser.browserAction.setPopup({ popup: "popup/popup.html" });
}
}
async function sendWithLoadingIndicator(url) {
browser.browserAction.setPopup({ popup: "popup/popup.html" });
browser.browserAction.openPopup();
triggerSendWithLoading(url);
async function startSendFlow(url) {
if (await getOneClickMode()) {
await sendToMeTube(url, await getDefaultSendOptions());
return;
}
await openPopupWithUrl(url);
}
browser.menus.onClicked.addListener(async function(info, tab) {
if (info.menuItemId === "send-to-metube" && info.linkUrl) {
await sendWithLoadingIndicator(info.linkUrl);
await startSendFlow(info.linkUrl);
} else if (info.menuItemId === "send-to-metube-page") {
await sendWithLoadingIndicator(tab.url);
await startSendFlow(tab.url);
}
});
@@ -301,11 +306,7 @@ updateBrowserActionPopup();
browser.commands.onCommand.addListener(async (command) => {
if (command === "send-to-metube") {
browser.browserAction.setPopup({ popup: "popup/popup.html" });
browser.browserAction.openPopup();
const url = await getCurrentUrl();
triggerSendWithLoading(url);
await startSendFlow(await getCurrentUrl());
}
});
+1 -6
View File
@@ -74,11 +74,6 @@ function hideLoadingState() {
}
browser.runtime.onMessage.addListener(async (message) => {
if (message.command === "showLoading") {
showLoadingState();
return;
}
hideLoadingState();
if (message.command === "errorOccurred") {
@@ -122,7 +117,7 @@ function getPopupSelects() {
}
addEventListener('DOMContentLoaded', async (event) => {
let url = await getCurrentUrl();
let url = new URLSearchParams(location.search).get('url') || await getCurrentUrl();
if (url && url.indexOf("://") === -1) url = "";
document.getElementById('urlInput').value = url || "";