A yt-dlp TUI for Omarchy. Dual-mode (audio/video) paste-and-queue downloader built with Go + Bubble Tea. Live progress, config view, clipboard launch, and an install.sh that pulls in yt-dlp/ffmpeg/wl-clipboard. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
36 lines
1.3 KiB
JavaScript
36 lines
1.3 KiB
JavaScript
// Adds a right-click entry that hands the chosen URL to the native omagrab app
|
|
// via the custom "omagrab:" URL scheme (registered by omagrab-url.desktop).
|
|
|
|
function createMenu() {
|
|
// removeAll first so reloads / service-worker restarts can't hit a
|
|
// "duplicate id" error that would leave the menu uncreated.
|
|
chrome.contextMenus.removeAll(() => {
|
|
chrome.contextMenus.create({
|
|
id: "omagrab",
|
|
title: "⏬ Download with omagrab",
|
|
contexts: ["link", "page", "video", "audio"],
|
|
});
|
|
});
|
|
}
|
|
|
|
chrome.runtime.onInstalled.addListener(createMenu);
|
|
chrome.runtime.onStartup.addListener(createMenu);
|
|
// also run on every service-worker spin-up, in case the events above were missed
|
|
createMenu();
|
|
|
|
chrome.contextMenus.onClicked.addListener((info, tab) => {
|
|
// Prefer the link the user clicked; otherwise fall back to the page itself
|
|
// (e.g. right-clicking anywhere on a video watch page).
|
|
const url = info.linkUrl || info.pageUrl || (tab && tab.url);
|
|
if (!url || !tab || tab.id == null) return;
|
|
|
|
const target = "omagrab:" + encodeURIComponent(url);
|
|
|
|
// Setting location.href on the active tab triggers the OS protocol handler
|
|
// without spawning a leftover blank tab. The page itself stays put.
|
|
chrome.scripting.executeScript({
|
|
target: { tabId: tab.id },
|
|
func: (u) => { window.location.href = u; },
|
|
args: [target],
|
|
});
|
|
});
|