diff --git a/Chrome/background.js b/Chrome/background.js index f2e9223..0e61b47 100644 --- a/Chrome/background.js +++ b/Chrome/background.js @@ -1,19 +1,18 @@ // Create context menu item chrome.runtime.onInstalled.addListener(() => { chrome.contextMenus.create({ - id: 'copy-clean-link', - title: 'Copy Clean YouTube Link', - contexts: ['link'] + id: 'copy-clean-link', + title: 'Copy Clean YouTube Link', + contexts: ['link'] }, () => { - if (chrome.runtime.lastError) { - console.error('Context menu creation failed:', chrome.runtime.lastError); - } else { - console.log('Context menu created successfully'); - } + if (chrome.runtime.lastError) { + console.error('Context menu creation failed:', chrome.runtime.lastError); + } else { + console.log('Context menu created successfully'); + } }); }); - // Handle context menu click chrome.contextMenus.onClicked.addListener((info, tab) => { if (info.menuItemId === 'copy-clean-link') { @@ -24,7 +23,7 @@ chrome.contextMenus.onClicked.addListener((info, tab) => { if (clickedUrl) { // Load settings and then clean the URL - chrome.storage.sync.get(["includeTimestamp", "includePlaylist"], (settings) => { + chrome.storage.sync.get(["includeTimestamp", "includePlaylist", "shortenLink"], (settings) => { let cleanUrl = cleanYouTubeUrl(clickedUrl, settings); console.log('Clean URL:', cleanUrl); @@ -52,21 +51,26 @@ function cleanYouTubeUrl(url, settings) { let playlistId = urlObj.searchParams.get('list'); let playlistIndex = urlObj.searchParams.get('index'); - let cleanedUrl = 'https://www.youtube.com/watch'; - if (videoId) { - cleanedUrl += `?v=${videoId}`; - } - if (settings.includeTimestamp && timestamp) { - cleanedUrl += `&t=${timestamp}`; - } - if (settings.includePlaylist && playlistId) { - cleanedUrl += `${videoId ? '&' : '?'}list=${playlistId}`; - if (playlistIndex) { - cleanedUrl += `&index=${playlistIndex}`; + // Check if the shortenLink setting is enabled + let cleanedUrl = settings.shortenLink ? `https://youtu.be/${videoId}` : `https://www.youtube.com/watch`; + + if (!settings.shortenLink) { + if (videoId) { + cleanedUrl += `?v=${videoId}`; + } + if (settings.includeTimestamp && timestamp) { + cleanedUrl += `&t=${timestamp}`; } + if (settings.includePlaylist && playlistId) { + cleanedUrl += `${videoId ? '&' : '?'}list=${playlistId}`; + if (playlistIndex) { + cleanedUrl += `&index=${playlistIndex}`; + } + } + } else if (settings.includeTimestamp && timestamp) { + // Add timestamp to shortened link if enabled + cleanedUrl += `?t=${timestamp}`; } return cleanedUrl; } - - \ No newline at end of file diff --git a/Chrome/manifest.json b/Chrome/manifest.json index 958a1b9..58f0d91 100644 --- a/Chrome/manifest.json +++ b/Chrome/manifest.json @@ -1,7 +1,7 @@ { "manifest_version": 3, "name": "YouTube Link Cleaner", - "version": "2.1.1", + "version": "2.2.0", "description": "Remove unnecessary parameters from YouTube URLs, keeping only video ID and timestamp.", "author": "raspberrykitty1", "permissions": ["contextMenus", "clipboardWrite", "activeTab", "storage", "scripting"], diff --git a/Chrome/popup.html b/Chrome/popup.html index 0357fd3..b4daa27 100644 --- a/Chrome/popup.html +++ b/Chrome/popup.html @@ -13,12 +13,13 @@ label { display: block; margin-bottom: 10px; + color: #000000 } /* Dark Theme (using prefers-color-scheme media query) */ @media (prefers-color-scheme: dark) { body { - background-color: #000000; + background-color: #121212; color: #ffffff; } label { @@ -36,6 +37,9 @@

Settings

+ diff --git a/Chrome/popup.js b/Chrome/popup.js index 4078816..2aa8571 100644 --- a/Chrome/popup.js +++ b/Chrome/popup.js @@ -6,13 +6,16 @@ document.addEventListener("DOMContentLoaded", () => { chrome.storage.sync.get(["includeTimestamp", "includePlaylist"], (data) => { includeTimestamp.checked = data.includeTimestamp ?? true; // Default to true includePlaylist.checked = data.includePlaylist ?? true; // Default to true + shortenLink.checked = data.shortenLink ?? true; // Default to true + }); // Save settings when the Save button is clicked document.getElementById("saveBtn").addEventListener("click", () => { chrome.storage.sync.set({ includeTimestamp: includeTimestamp.checked, - includePlaylist: includePlaylist.checked + includePlaylist: includePlaylist.checked, + shortenLink: shortenLink.checked }, () => { alert("Settings saved!"); }); diff --git a/Firefox/background.js b/Firefox/background.js index 1236a63..7178e6c 100644 --- a/Firefox/background.js +++ b/Firefox/background.js @@ -17,17 +17,25 @@ browser.contextMenus.onClicked.addListener((info, tab) => { if (videoId) { // Load settings to determine which parameters to include - browser.storage.sync.get(["includeTimestamp", "includePlaylist"]).then((settings) => { - let cleanUrl = `https://www.youtube.com/watch?v=${videoId}`; + browser.storage.sync.get(["includeTimestamp", "includePlaylist", "shortenLink"]).then((settings) => { + // Determine whether to shorten the link + let cleanUrl = settings.shortenLink ? `https://youtu.be/${videoId}` : `https://www.youtube.com/watch?v=${videoId}`; // Add optional parameters if they exist and if the settings allow it - if (settings.includeTimestamp && timestamp) { - cleanUrl += `&t=${timestamp}`; - } - if (settings.includePlaylist && playlistId) { - cleanUrl += `&list=${playlistId}`; - if (playlistIndex) { - cleanUrl += `&index=${playlistIndex}`; + if (settings.shortenLink) { + // Only include timestamp with shortened links + if (settings.includeTimestamp && timestamp) { + cleanUrl += `?t=${timestamp}`; + } + } else { + if (settings.includeTimestamp && timestamp) { + cleanUrl += `&t=${timestamp}`; + } + if (settings.includePlaylist && playlistId) { + cleanUrl += `&list=${playlistId}`; + if (playlistIndex) { + cleanUrl += `&index=${playlistIndex}`; + } } } diff --git a/Firefox/manifest.json b/Firefox/manifest.json index bb5d2b7..0320d84 100644 --- a/Firefox/manifest.json +++ b/Firefox/manifest.json @@ -1,7 +1,7 @@ { "manifest_version": 2, "name": "YouTube Link Cleaner", - "version": "2.1.1", + "version": "2.2.0", "description": "Remove unnecessary parameters from YouTube URLs, keeping only video ID and timestamp.", "author": "raspberrykitty1", "permissions": ["contextMenus", "clipboardWrite", "activeTab", "storage"], diff --git a/Firefox/popup.html b/Firefox/popup.html index c5a1040..b4daa27 100644 --- a/Firefox/popup.html +++ b/Firefox/popup.html @@ -37,6 +37,9 @@

Settings

+ diff --git a/Firefox/popup.js b/Firefox/popup.js index 6ea01c1..7a3a019 100644 --- a/Firefox/popup.js +++ b/Firefox/popup.js @@ -1,18 +1,21 @@ document.addEventListener("DOMContentLoaded", () => { const includeTimestamp = document.getElementById("includeTimestamp"); const includePlaylist = document.getElementById("includePlaylist"); - + const shortenLink = document.getElementById("shortenLink"); + // Load stored settings browser.storage.sync.get(["includeTimestamp", "includePlaylist"]).then((data) => { includeTimestamp.checked = data.includeTimestamp ?? true; // Default to true includePlaylist.checked = data.includePlaylist ?? true; // Default to true + shortenLink.checked = data.shortenLink ?? true; // Default to true }); // Save settings when the Save button is clicked document.getElementById("saveBtn").addEventListener("click", () => { browser.storage.sync.set({ includeTimestamp: includeTimestamp.checked, - includePlaylist: includePlaylist.checked + includePlaylist: includePlaylist.checked, + shortenLink: shortenLink.checked }).then(() => { alert("Settings saved!"); }); diff --git a/Releases/Chrome/Youtube Copy Clean Link 1.1 (Chromium Based Browser).zip b/Releases/Chrome/Youtube Copy Clean Link 1.1 (Chromium Based Browser).zip new file mode 100644 index 0000000..4014369 Binary files /dev/null and b/Releases/Chrome/Youtube Copy Clean Link 1.1 (Chromium Based Browser).zip differ diff --git a/Releases/Chrome/Youtube Copy Clean Link 1.2 (Chromium Based Browser).zip b/Releases/Chrome/Youtube Copy Clean Link 1.2 (Chromium Based Browser).zip new file mode 100644 index 0000000..abe6ae6 Binary files /dev/null and b/Releases/Chrome/Youtube Copy Clean Link 1.2 (Chromium Based Browser).zip differ diff --git a/Releases/Chrome/Youtube Copy Clean Link 1.2.1 (Chromium Based Browser).zip b/Releases/Chrome/Youtube Copy Clean Link 1.2.1 (Chromium Based Browser).zip new file mode 100644 index 0000000..8d5a6ee Binary files /dev/null and b/Releases/Chrome/Youtube Copy Clean Link 1.2.1 (Chromium Based Browser).zip differ diff --git a/Releases/Chrome/Youtube Copy Clean Link 2.0.0 (Chromium Based Browser).zip b/Releases/Chrome/Youtube Copy Clean Link 2.0.0 (Chromium Based Browser).zip new file mode 100644 index 0000000..52f26d6 Binary files /dev/null and b/Releases/Chrome/Youtube Copy Clean Link 2.0.0 (Chromium Based Browser).zip differ diff --git a/Releases/Chrome/Youtube Copy Clean Link 2.1.0 (Chromium Based Browser).zip b/Releases/Chrome/Youtube Copy Clean Link 2.1.0 (Chromium Based Browser).zip new file mode 100644 index 0000000..b408bc5 Binary files /dev/null and b/Releases/Chrome/Youtube Copy Clean Link 2.1.0 (Chromium Based Browser).zip differ diff --git a/Releases/Chrome/Youtube Copy Clean Link 2.1.1 (Chromium Based Browser).zip b/Releases/Chrome/Youtube Copy Clean Link 2.1.1 (Chromium Based Browser).zip new file mode 100644 index 0000000..6504afa Binary files /dev/null and b/Releases/Chrome/Youtube Copy Clean Link 2.1.1 (Chromium Based Browser).zip differ diff --git a/Releases/Firefox/8aa8ecf3aedf4305bd9f-1.0.xpi b/Releases/Firefox/8aa8ecf3aedf4305bd9f-1.0.xpi new file mode 100644 index 0000000..cc3c6a3 Binary files /dev/null and b/Releases/Firefox/8aa8ecf3aedf4305bd9f-1.0.xpi differ diff --git a/Releases/Firefox/8aa8ecf3aedf4305bd9f-1.1.xpi b/Releases/Firefox/8aa8ecf3aedf4305bd9f-1.1.xpi new file mode 100644 index 0000000..18dbe42 Binary files /dev/null and b/Releases/Firefox/8aa8ecf3aedf4305bd9f-1.1.xpi differ diff --git a/Releases/Firefox/8aa8ecf3aedf4305bd9f-1.2.1.xpi b/Releases/Firefox/8aa8ecf3aedf4305bd9f-1.2.1.xpi new file mode 100644 index 0000000..f62ec68 Binary files /dev/null and b/Releases/Firefox/8aa8ecf3aedf4305bd9f-1.2.1.xpi differ diff --git a/Releases/Firefox/8aa8ecf3aedf4305bd9f-1.2.xpi b/Releases/Firefox/8aa8ecf3aedf4305bd9f-1.2.xpi new file mode 100644 index 0000000..7d4a255 Binary files /dev/null and b/Releases/Firefox/8aa8ecf3aedf4305bd9f-1.2.xpi differ diff --git a/Releases/Firefox/8aa8ecf3aedf4305bd9f-2.0.0.xpi b/Releases/Firefox/8aa8ecf3aedf4305bd9f-2.0.0.xpi new file mode 100644 index 0000000..43f5170 Binary files /dev/null and b/Releases/Firefox/8aa8ecf3aedf4305bd9f-2.0.0.xpi differ diff --git a/Releases/Firefox/8aa8ecf3aedf4305bd9f-2.1.0.xpi b/Releases/Firefox/8aa8ecf3aedf4305bd9f-2.1.0.xpi new file mode 100644 index 0000000..15a0131 Binary files /dev/null and b/Releases/Firefox/8aa8ecf3aedf4305bd9f-2.1.0.xpi differ diff --git a/Releases/Firefox/8aa8ecf3aedf4305bd9f-2.1.1.xpi b/Releases/Firefox/8aa8ecf3aedf4305bd9f-2.1.1.xpi new file mode 100644 index 0000000..a658602 Binary files /dev/null and b/Releases/Firefox/8aa8ecf3aedf4305bd9f-2.1.1.xpi differ