shorts fix

This commit is contained in:
Anarios
2025-08-25 09:12:25 +02:00
parent bb527d6da1
commit 70d4fda075
3 changed files with 43 additions and 3 deletions
+1 -1
View File
@@ -16,7 +16,7 @@ let isSetInitialStateDone = false;
async function setEventListeners(evt) {
async function checkForJS_Finish() {
try {
if (isShorts() || (getButtons()?.offsetParent && isVideoLoaded())) {
if ((isShorts() && isVideoLoaded()) || (getButtons()?.offsetParent && isVideoLoaded())) {
clearInterval(jsInitChecktimer);
jsInitChecktimer = null;
createSmartimationObserver();
+41 -1
View File
@@ -1,4 +1,4 @@
import { extConfig } from "./state";
import { extConfig, isShorts } from "./state";
function numberFormat(numberState) {
return getNumberFormatter(extConfig.numberDisplayFormat).format(numberState);
@@ -91,8 +91,48 @@ function isInViewport(element) {
);
}
function isShortsLoaded(videoId) {
if (!videoId) return false;
// Find all reel containers
const reelContainers = document.querySelectorAll(".reel-video-in-sequence-new");
for (const container of reelContainers) {
// Check if this container's thumbnail matches our video ID
const thumbnail = container.querySelector(".reel-video-in-sequence-thumbnail");
if (thumbnail) {
const bgImage = thumbnail.style.backgroundImage;
// YouTube thumbnail URLs contain the video ID in the format: /vi/VIDEO_ID/
if ((bgImage && bgImage.includes(`/${videoId}/`)) || (!bgImage && isInViewport(container))) {
// Check if this container has the renderer with visible experiment-overlay
const renderer = container.querySelector("ytd-reel-video-renderer");
if (renderer) {
const experimentOverlay = renderer.querySelector("#experiment-overlay");
if (
experimentOverlay &&
!experimentOverlay.hidden &&
window.getComputedStyle(experimentOverlay).display !== "none" &&
experimentOverlay.hasChildNodes()
) {
return true;
}
}
}
}
}
return false;
}
function isVideoLoaded() {
const videoId = getVideoId(window.location.href);
// Check if this is a Shorts URL
if (isShorts()) {
return isShortsLoaded(videoId);
}
// Regular video checks
return (
// desktop: spring 2024 UI
document.querySelector(`ytd-watch-grid[video-id='${videoId}']`) !== null ||
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "return-youtube-dislike",
"version": "3.0.0-18",
"version": "3.0.0-19",
"description": "Chrome extension to return youtube dislikes",
"main": "ryd.content-script.js",
"scripts": {