Add a "save channel" button at the bottom of the popup that switches to a new view. The view is only active if the currently open tab's URL contains youtube.com.*/videos. The view contains:
Template string:
curl -X POST -H 'content-type: application/json' -d '{"query": "mutation add{ addChannel(details: {category: \"<category>\", checkInterval: <interval>, name: \"<title>\", url: \"<url>\"}){name} } "}' localhost:8543/data | jq '.'
Where:
<category> is the currently selected category (defaulting to "FOR BOTH")<interval> is the check interval in days (defaulting to 14)<title> is the page title with trailing " - YouTube" removed<url> is the URL of the currently active tabCategories: "FOR BOTH", "CHANNELS", "CREATIVE"
clipboardWrite permission for copy functionalitycurrentView to include "saveChannel" stateAdded properties:
isCurrentTabChannelPage: Detects YouTube /videos pages (renamed from isCurrentTabYoutubeVideos)selectedCategory: Tracks selected category (default "FOR BOTH")availableCategories: Array of category optionscurlCommand: Generated curl command stringcheckInterval: Check interval in days (default 14)Added methods:
updateCurlCommand(): Generates curl command based on current tab, category, and intervalcopyCurlCommand(): Copies command to clipboard with fallbackselectCategory(category): Updates selected category and regenerates commandupdateCheckInterval(interval): Updates check interval with validation and regenerates commandshowSaveChannel(): Switches to save channel viewAdded event bindings (CSP-compliant):
saveChannelButton: Click handler for main save channel buttonsaveChannelContainer: View visibility bindingsaveChannelHeader: Header visibility bindingcopyCurlButton: Copy button click handler with disabled state for non-channel pagescategoryButton: Category selection with active state stylingintervalInput: Two-way binding for interval number inputsaveChannelNotice: Notice visibility for non-YouTube videos pagesThe feature only activates when the current tab URL contains /videos, which typically corresponds to YouTube channel video listing pages (e.g., https://www.youtube.com/@channel/videos).
Implements both modern clipboard API and fallback for older browsers using document.execCommand. The copy button is disabled when not on a valid YouTube channel page.
manifest.json: Added clipboardWrite permissionpopup/popup.html: Added save channel view, button, and interval inputpopup/popup.js: Added save channel functionality, interval handling, and bindingspopup/popup.css: Added styling for save channel components and interval inputThe feature gracefully handles non-YouTube pages by showing an informational notice and disabling the copy button.
The textarea field is currently readonly and auto-generated based on user selections (category and interval).
Making the textarea user-editable would provide additional flexibility. Implementation considerations:
readonly attribute from textareax-text to x-model for two-way bindingThis enhancement would balance user flexibility with automatic generation convenience, but requires careful consideration of the user experience and conflict resolution strategies.