mirror of
https://github.com/Alvin-Zilverstand/return-youtube-dislike.git
synced 2026-12-02 10:52:20 +01:00
move isVideoLoaded to utils.js
This commit is contained in:
1 parent
689b0b7f8c
commit
e6a1716e7e
2 files changed
+11
-11
No files matched your search
@@ -17,7 +17,7 @@ import {
|
|||||||
DISLIKED_STATE,
|
DISLIKED_STATE,
|
||||||
NEUTRAL_STATE,
|
NEUTRAL_STATE,
|
||||||
} from "./src/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";
|
import { createRateBar } from "./src/bar";
|
||||||
|
|
||||||
let storedData = {
|
let storedData = {
|
||||||
@@ -89,15 +89,6 @@ function setInitialState() {
|
|||||||
}, 1500);
|
}, 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;
|
let jsInitChecktimer = null;
|
||||||
|
|
||||||
function setEventListeners(evt) {
|
function setEventListeners(evt) {
|
||||||
|
|||||||
@@ -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) {
|
function cLog(message, writer) {
|
||||||
message = `[return youtube dislike]: ${message}`;
|
message = `[return youtube dislike]: ${message}`;
|
||||||
if (writer) {
|
if (writer) {
|
||||||
@@ -58,4 +67,4 @@ function cLog(message, writer) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export { numberFormat, getBrowser, getVideoId, cLog }
|
export { numberFormat, getBrowser, getVideoId, isVideoLoaded, cLog }
|
||||||
Reference in new issue
Block a user