mirror of
https://github.com/Alvin-Zilverstand/return-youtube-dislike.git
synced 2026-12-02 02:41:22 +01:00
Extension - New (spring 2024) UI support (#1045)
* Extension - new (spring 2024) UI support Add new player selector for isVideoLoaded() (fixes #1043) * Githook tasks for fd45f86f (in a separate commit for readability)
This commit is contained in:
1 parent
2882cfd6e6
commit
1ed03f7cc9
1 file changed
+5
-7
@@ -18,9 +18,7 @@ function getNumberFormatter(optionSelect) {
|
|||||||
?.getAttribute("href"),
|
?.getAttribute("href"),
|
||||||
)?.searchParams?.get("locale");
|
)?.searchParams?.get("locale");
|
||||||
} catch {
|
} catch {
|
||||||
cLog(
|
cLog("Cannot find browser locale. Use en as default for number formatting.");
|
||||||
"Cannot find browser locale. Use en as default for number formatting.",
|
|
||||||
);
|
|
||||||
userLocales = "en";
|
userLocales = "en";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -56,10 +54,7 @@ function localize(localeString) {
|
|||||||
function getBrowser() {
|
function getBrowser() {
|
||||||
if (typeof chrome !== "undefined" && typeof chrome.runtime !== "undefined") {
|
if (typeof chrome !== "undefined" && typeof chrome.runtime !== "undefined") {
|
||||||
return chrome;
|
return chrome;
|
||||||
} else if (
|
} else if (typeof browser !== "undefined" && typeof browser.runtime !== "undefined") {
|
||||||
typeof browser !== "undefined" &&
|
|
||||||
typeof browser.runtime !== "undefined"
|
|
||||||
) {
|
|
||||||
return browser;
|
return browser;
|
||||||
} else {
|
} else {
|
||||||
console.log("browser is not supported");
|
console.log("browser is not supported");
|
||||||
@@ -98,6 +93,9 @@ function isInViewport(element) {
|
|||||||
function isVideoLoaded() {
|
function isVideoLoaded() {
|
||||||
const videoId = getVideoId(window.location.href);
|
const videoId = getVideoId(window.location.href);
|
||||||
return (
|
return (
|
||||||
|
// desktop: spring 2024 UI
|
||||||
|
document.querySelector(`ytd-watch-grid[video-id='${videoId}']`) !== null ||
|
||||||
|
// desktop: older UI
|
||||||
document.querySelector(`ytd-watch-flexy[video-id='${videoId}']`) !== null ||
|
document.querySelector(`ytd-watch-flexy[video-id='${videoId}']`) !== null ||
|
||||||
// mobile: no video-id attribute
|
// mobile: no video-id attribute
|
||||||
document.querySelector('#player[loading="false"]:not([hidden])') !== null
|
document.querySelector('#player[loading="false"]:not([hidden])') !== null
|
||||||
|
|||||||
Reference in new issue
Block a user