From e6a1716e7e59b12c7baef0781a5be11380490a3c Mon Sep 17 00:00:00 2001 From: Leon Bubova Date: Sat, 18 Dec 2021 00:48:44 +0100 Subject: [PATCH] move isVideoLoaded to utils.js --- Extensions/combined/ryd.content-script.js | 11 +---------- Extensions/combined/src/utils.js | 11 ++++++++++- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Extensions/combined/ryd.content-script.js b/Extensions/combined/ryd.content-script.js index e1f5dce..059d6f1 100644 --- a/Extensions/combined/ryd.content-script.js +++ b/Extensions/combined/ryd.content-script.js @@ -17,7 +17,7 @@ import { DISLIKED_STATE, NEUTRAL_STATE, } from "./src/state"; -import { numberFormat, getBrowser, getVideoId, cLog } from "./src/utils"; +import { numberFormat, getBrowser, getVideoId, isVideoLoaded, cLog } from "./src/utils"; import { createRateBar } from "./src/bar"; let storedData = { @@ -89,15 +89,6 @@ function setInitialState() { }, 1500); } -function isVideoLoaded() { - const videoId = getVideoId(window.location.href); - return ( - document.querySelector(`ytd-watch-flexy[video-id='${videoId}']`) !== null || - // mobile: no video-id attribute - document.querySelector('#player[loading="false"]:not([hidden])') !== null - ); -} - let jsInitChecktimer = null; function setEventListeners(evt) { diff --git a/Extensions/combined/src/utils.js b/Extensions/combined/src/utils.js index a7a12a5..e1c6dbe 100644 --- a/Extensions/combined/src/utils.js +++ b/Extensions/combined/src/utils.js @@ -49,6 +49,15 @@ function getVideoId(url) { } } +function isVideoLoaded() { + const videoId = getVideoId(window.location.href); + return ( + document.querySelector(`ytd-watch-flexy[video-id='${videoId}']`) !== null || + // mobile: no video-id attribute + document.querySelector('#player[loading="false"]:not([hidden])') !== null + ); +} + function cLog(message, writer) { message = `[return youtube dislike]: ${message}`; if (writer) { @@ -58,4 +67,4 @@ function cLog(message, writer) { } } -export { numberFormat, getBrowser, getVideoId, cLog } \ No newline at end of file +export { numberFormat, getBrowser, getVideoId, isVideoLoaded, cLog } \ No newline at end of file