Merge branch 'main' into CustomNumberFormat

This commit is contained in:
Dmitrii Selivanov authored and GitHub committed 2022-03-20 20:32:21 +03:00
commit e97b4a75af
29 files changed
+520 -91

No files matched your search

+16 -1
View File
@@ -78,10 +78,25 @@ function getVideoId(url) {
if (pathname.startsWith("/clip")) {
return document.querySelector("meta[itemprop='videoId']").content;
} else {
if (pathname.startsWith("/shorts")) {
return pathname.substr(8);
}
return urlObject.searchParams.get("v");
}
}
function isInViewport(element) {
const rect = element.getBoundingClientRect();
const height = innerHeight || document.documentElement.clientHeight;
const width = innerWidth || document.documentElement.clientWidth;
return (
rect.top >= 0 &&
rect.left >= 0 &&
rect.bottom <= height &&
rect.right <= width
);
}
function isVideoLoaded() {
const videoId = getVideoId(window.location.href);
return (
@@ -100,4 +115,4 @@ function cLog(message, writer) {
}
}
export { numberFormat, getBrowser, getVideoId, isVideoLoaded, cLog }
export { numberFormat, getBrowser, getVideoId, isInViewport, isVideoLoaded, cLog }