From 540600731595bcd9f4a8d3878d17f7e33b2cca1d Mon Sep 17 00:00:00 2001 From: Simon Date: Tue, 31 Oct 2023 16:59:38 +0700 Subject: [PATCH] add dl button to shorts results --- extension/script.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/extension/script.js b/extension/script.js index 8a6a319..ce83d1e 100644 --- a/extension/script.js +++ b/extension/script.js @@ -312,8 +312,13 @@ function buildVideoButton(titleContainer) { dlButton.classList.add('ta-button'); dlButton.href = '#'; - let params = new URLSearchParams(href); - let videoId = params.get('/watch?v'); + let videoId; + if (href.startsWith('/watch?v')) { + let params = new URLSearchParams(href); + videoId = params.get('/watch?v'); + } else if (href.startsWith('/shorts/')) { + videoId = href.split('/')[2]; + } if (!videoId) return; dlButton.setAttribute('data-id', videoId); @@ -365,7 +370,7 @@ function getNearestLink(element) { } function processTitle(titleContainer) { - if (titleContainer.hasListener) return + if (titleContainer.hasListener) return; Object.assign(titleContainer.style, { display: 'flex', gap: '15px',