From 24ae92ea581a43bc6a0df60aec9091c39abf04d0 Mon Sep 17 00:00:00 2001 From: Ryan Thaut Date: Wed, 21 Jun 2023 13:42:22 -0600 Subject: [PATCH] Fix #392 Auto-Open Bug (#408) * remove `tabs.onUpdated` event filter (only supported in Firefox) * fix `VideoIDRegEx` pattern to not match embedded URLs --- app/scripts/background.js | 17 +++++------------ app/scripts/helpers/youtube.js | 3 +-- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/app/scripts/background.js b/app/scripts/background.js index 2d683ed..7be5117 100644 --- a/app/scripts/background.js +++ b/app/scripts/background.js @@ -2,7 +2,6 @@ import { OnCommandEventHandler } from "./background/commands"; import { InitMenus } from "./background/menus"; import { OpenPopoutBackgroundHelper } from "./background/popout"; import { OnInstalled, OnRuntimeMessage } from "./background/runtime"; -import { YOUTUBE_VIDEO_URL_PATTERNS } from "./helpers/constants"; import { GetExtraInfoSpec, GetFilter, @@ -42,18 +41,12 @@ browser.webRequest.onSendHeaders.addListener( GetExtraInfoSpec("onSendHeaders") ); -browser.tabs.onUpdated.addListener( - async (tabId, changeInfo) => { - if (changeInfo.url && IsVideoURL(changeInfo.url, false)) { - if (await Options.GetLocalOption("advanced", "autoOpen")) { - OpenPopoutBackgroundHelper(changeInfo.url, tabId, false); - } +browser.tabs.onUpdated.addListener(async (tabId, changeInfo) => { + if (changeInfo.url && IsVideoURL(changeInfo.url, false)) { + if (await Options.GetLocalOption("advanced", "autoOpen")) { + OpenPopoutBackgroundHelper(changeInfo.url, tabId, false); } - }, - { - properties: ["status", "url"], - urls: YOUTUBE_VIDEO_URL_PATTERNS, } -); +}); InitMenus(); diff --git a/app/scripts/helpers/youtube.js b/app/scripts/helpers/youtube.js index 8adee47..2ab1fd4 100644 --- a/app/scripts/helpers/youtube.js +++ b/app/scripts/helpers/youtube.js @@ -1,7 +1,6 @@ import { GetParamFromURL } from "./utils"; -export const VideoIDRegEx = - /(?:(?:v=)|(?:\/embed\/)|(?:\/shorts\/))([^\?\&\/]{11})/; +export const VideoIDRegEx = /(?:(?:v=)|(?:\/shorts\/))([^\?\&\/]{11})/; export const VideoLinkOrEmbedRegEx = /(?:(?:v=)|(?:\/embed\/)|(?:\/shorts\/)|(?:\/youtu\.be\/))([^\?\&\/]{11})/;