From 49a36f5ecab5e22d0ce89674aceed9aa9ffa8965 Mon Sep 17 00:00:00 2001 From: BillK <35489013+Bill13579@users.noreply.github.com> Date: Sat, 7 Sep 2024 07:47:04 +0800 Subject: [PATCH] Fixed rename icon; added more hooks for detecting page navigation; updated YouTube metadata selectors; updated browser check for muted --- dist/popup/popup.css | 4 ++-- src/background/captureTab.js | 2 ++ src/content/packd.js | 4 ++-- src/tapi/ttab.js | 2 ++ 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/dist/popup/popup.css b/dist/popup/popup.css index d6f4781..5579785 100644 --- a/dist/popup/popup.css +++ b/dist/popup/popup.css @@ -203,7 +203,7 @@ input[type="text"]:focus { } .-tui-menu-item { display: inline-block; - /* height: calc(26px * var(--scale)); */ + height: calc(26px * var(--scale)); line-height: calc(26px * var(--scale)); padding-left: 8px; padding-right: calc(8px + 4.5px); @@ -229,7 +229,7 @@ input[type="text"]:focus { vertical-align: middle; mask-repeat: no-repeat; - mask-size: contain; + /* mask-size: contain; */ } .-tui-menu-item .-tui-menu-item-label { color: var(--fg-lite); diff --git a/src/background/captureTab.js b/src/background/captureTab.js index d4737af..64c771c 100644 --- a/src/background/captureTab.js +++ b/src/background/captureTab.js @@ -194,7 +194,9 @@ const webNavigationListener = async ({tabId, url}) => { }); }; browser.webNavigation.onHistoryStateUpdated.addListener(webNavigationListener); +browser.webNavigation.onReferenceFragmentUpdated.addListener(webNavigationListener); browser.webNavigation.onCompleted.addListener(webNavigationListener); +browser.tabs.onUpdated.addListener((tabId, {url}, _) => webNavigationListener({tabId, url})); browser.tabs.onRemoved.addListener((tabId, _) => { let updatePromise = lastUpdatePromise; diff --git a/src/content/packd.js b/src/content/packd.js index d7c2b1f..8e95bce 100644 --- a/src/content/packd.js +++ b/src/content/packd.js @@ -52,12 +52,12 @@ function waitForElementValueToChange(element) { const MUTATION_OBSERVERS = { "www.youtube.com": () => new Promise(async (resolve, reject) => { if (window.location.pathname.startsWith("/watch")) { - let ele = document.querySelector('#meta-contents #description yt-formatted-string.content'); + let ele = document.querySelector('ytd-watch-metadata'); if (ele) { let value = await waitForElementValueToChange(ele); resolve(value); } else { - let value = await waitForElementToExist('#meta-contents #description yt-formatted-string.content'); + let value = await waitForElementToExist('ytd-watch-metadata'); resolve(value.textContent); } } else { diff --git a/src/tapi/ttab.js b/src/tapi/ttab.js index f503818..0f3d4c4 100644 --- a/src/tapi/ttab.js +++ b/src/tapi/ttab.js @@ -167,6 +167,8 @@ export class TTab { prefs.discarded = ttab.discarded; prefs.openInReaderMode = ttab.isInReaderMode; prefs.title = ttab.discarded ? ttab.title : undefined; + } + if (TargetBrowser === "firefox" || TargetBrowser === "webext") { prefs.muted = ttab.mutedInfo.muted; } return browser.tabs.create(prefs);