Skip to content

Commit

Permalink
Fix #392 Auto-Open Bug (#408)
Browse files Browse the repository at this point in the history
* remove `tabs.onUpdated` event filter (only supported in Firefox)
* fix `VideoIDRegEx` pattern to not match embedded URLs
  • Loading branch information
rthaut authored Jun 21, 2023
1 parent dbac884 commit 24ae92e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 14 deletions.
17 changes: 5 additions & 12 deletions app/scripts/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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();
3 changes: 1 addition & 2 deletions app/scripts/helpers/youtube.js
Original file line number Diff line number Diff line change
@@ -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})/;
Expand Down

0 comments on commit 24ae92e

Please sign in to comment.