mirror of
https://github.com/MarshalX/telegram-crawler.git
synced 2025-01-16 14:43:05 +01:00
Update content of files
This commit is contained in:
parent
91c0741c13
commit
f7dcd9af07
3 changed files with 39 additions and 6 deletions
|
@ -384,12 +384,12 @@ function initScrollVideos(desktop) {
|
||||||
|
|
||||||
var index = 1;
|
var index = 1;
|
||||||
var tgStickersCnt = document.querySelectorAll('.js-tgsticker_image').length;
|
var tgStickersCnt = document.querySelectorAll('.js-tgsticker_image').length;
|
||||||
var preloadVideos = tgStickersCnt ? 0 : 2;
|
var preloadVideos = tgStickersCnt > 1 ? 0 : (tgStickersCnt ? 1 : 2);
|
||||||
var isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
|
var isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
|
||||||
for (var i = 0; i < pageVideos.length; i++) {
|
for (var i = 0; i < pageVideos.length; i++) {
|
||||||
var videoEl = pageVideos[i];
|
var videoEl = pageVideos[i];
|
||||||
videoEl.setAttribute('vindex', index++);
|
videoEl.setAttribute('vindex', index++);
|
||||||
var preloadValue = i >= preloadVideos ? 'metadata' : 'auto';
|
var preloadValue = i >= preloadVideos ? (isSafari ? 'none' : 'metadata') : 'auto';
|
||||||
videoEl.setAttribute('preload', preloadValue);
|
videoEl.setAttribute('preload', preloadValue);
|
||||||
videoEl.preload = preloadValue;
|
videoEl.preload = preloadValue;
|
||||||
if (desktop) {
|
if (desktop) {
|
||||||
|
@ -407,6 +407,7 @@ function initScrollVideos(desktop) {
|
||||||
videoEl.parentNode.style.background = "url('" + escapeHTML(posterUrl) + "') center no-repeat";
|
videoEl.parentNode.style.background = "url('" + escapeHTML(posterUrl) + "') center no-repeat";
|
||||||
videoEl.parentNode.style.backgroundSize = "cover";
|
videoEl.parentNode.style.backgroundSize = "cover";
|
||||||
videoEl.parentNode.style.lineHeight = "0";
|
videoEl.parentNode.style.lineHeight = "0";
|
||||||
|
videoPreloadPosterDimensions(videoEl, posterUrl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!desktop) {
|
if (!desktop) {
|
||||||
|
@ -451,6 +452,16 @@ function checkScrollVideos() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function videoPreloadPosterDimensions(videoEl, posterUrl) {
|
||||||
|
var img = new Image();
|
||||||
|
img.onload = function () {
|
||||||
|
if (img.width > 0 && img.height > 0) {
|
||||||
|
videoEl.style.aspectRatio = img.width / img.height;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
img.src = posterUrl;
|
||||||
|
}
|
||||||
|
|
||||||
function isVisibleEnough(boxOffset, boxSize, viewOffset, viewSize, boxThreshold, viewThreshold) {
|
function isVisibleEnough(boxOffset, boxSize, viewOffset, viewSize, boxThreshold, viewThreshold) {
|
||||||
var boxEnd = boxOffset + boxSize;
|
var boxEnd = boxOffset + boxSize;
|
||||||
var viewEnd = viewOffset + viewSize;
|
var viewEnd = viewOffset + viewSize;
|
||||||
|
|
|
@ -384,12 +384,12 @@ function initScrollVideos(desktop) {
|
||||||
|
|
||||||
var index = 1;
|
var index = 1;
|
||||||
var tgStickersCnt = document.querySelectorAll('.js-tgsticker_image').length;
|
var tgStickersCnt = document.querySelectorAll('.js-tgsticker_image').length;
|
||||||
var preloadVideos = tgStickersCnt ? 0 : 2;
|
var preloadVideos = tgStickersCnt > 1 ? 0 : (tgStickersCnt ? 1 : 2);
|
||||||
var isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
|
var isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
|
||||||
for (var i = 0; i < pageVideos.length; i++) {
|
for (var i = 0; i < pageVideos.length; i++) {
|
||||||
var videoEl = pageVideos[i];
|
var videoEl = pageVideos[i];
|
||||||
videoEl.setAttribute('vindex', index++);
|
videoEl.setAttribute('vindex', index++);
|
||||||
var preloadValue = i >= preloadVideos ? 'metadata' : 'auto';
|
var preloadValue = i >= preloadVideos ? (isSafari ? 'none' : 'metadata') : 'auto';
|
||||||
videoEl.setAttribute('preload', preloadValue);
|
videoEl.setAttribute('preload', preloadValue);
|
||||||
videoEl.preload = preloadValue;
|
videoEl.preload = preloadValue;
|
||||||
if (desktop) {
|
if (desktop) {
|
||||||
|
@ -407,6 +407,7 @@ function initScrollVideos(desktop) {
|
||||||
videoEl.parentNode.style.background = "url('" + escapeHTML(posterUrl) + "') center no-repeat";
|
videoEl.parentNode.style.background = "url('" + escapeHTML(posterUrl) + "') center no-repeat";
|
||||||
videoEl.parentNode.style.backgroundSize = "cover";
|
videoEl.parentNode.style.backgroundSize = "cover";
|
||||||
videoEl.parentNode.style.lineHeight = "0";
|
videoEl.parentNode.style.lineHeight = "0";
|
||||||
|
videoPreloadPosterDimensions(videoEl, posterUrl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!desktop) {
|
if (!desktop) {
|
||||||
|
@ -451,6 +452,16 @@ function checkScrollVideos() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function videoPreloadPosterDimensions(videoEl, posterUrl) {
|
||||||
|
var img = new Image();
|
||||||
|
img.onload = function () {
|
||||||
|
if (img.width > 0 && img.height > 0) {
|
||||||
|
videoEl.style.aspectRatio = img.width / img.height;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
img.src = posterUrl;
|
||||||
|
}
|
||||||
|
|
||||||
function isVisibleEnough(boxOffset, boxSize, viewOffset, viewSize, boxThreshold, viewThreshold) {
|
function isVisibleEnough(boxOffset, boxSize, viewOffset, viewSize, boxThreshold, viewThreshold) {
|
||||||
var boxEnd = boxOffset + boxSize;
|
var boxEnd = boxOffset + boxSize;
|
||||||
var viewEnd = viewOffset + viewSize;
|
var viewEnd = viewOffset + viewSize;
|
||||||
|
|
|
@ -384,12 +384,12 @@ function initScrollVideos(desktop) {
|
||||||
|
|
||||||
var index = 1;
|
var index = 1;
|
||||||
var tgStickersCnt = document.querySelectorAll('.js-tgsticker_image').length;
|
var tgStickersCnt = document.querySelectorAll('.js-tgsticker_image').length;
|
||||||
var preloadVideos = tgStickersCnt ? 0 : 2;
|
var preloadVideos = tgStickersCnt > 1 ? 0 : (tgStickersCnt ? 1 : 2);
|
||||||
var isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
|
var isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
|
||||||
for (var i = 0; i < pageVideos.length; i++) {
|
for (var i = 0; i < pageVideos.length; i++) {
|
||||||
var videoEl = pageVideos[i];
|
var videoEl = pageVideos[i];
|
||||||
videoEl.setAttribute('vindex', index++);
|
videoEl.setAttribute('vindex', index++);
|
||||||
var preloadValue = i >= preloadVideos ? 'metadata' : 'auto';
|
var preloadValue = i >= preloadVideos ? (isSafari ? 'none' : 'metadata') : 'auto';
|
||||||
videoEl.setAttribute('preload', preloadValue);
|
videoEl.setAttribute('preload', preloadValue);
|
||||||
videoEl.preload = preloadValue;
|
videoEl.preload = preloadValue;
|
||||||
if (desktop) {
|
if (desktop) {
|
||||||
|
@ -407,6 +407,7 @@ function initScrollVideos(desktop) {
|
||||||
videoEl.parentNode.style.background = "url('" + escapeHTML(posterUrl) + "') center no-repeat";
|
videoEl.parentNode.style.background = "url('" + escapeHTML(posterUrl) + "') center no-repeat";
|
||||||
videoEl.parentNode.style.backgroundSize = "cover";
|
videoEl.parentNode.style.backgroundSize = "cover";
|
||||||
videoEl.parentNode.style.lineHeight = "0";
|
videoEl.parentNode.style.lineHeight = "0";
|
||||||
|
videoPreloadPosterDimensions(videoEl, posterUrl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!desktop) {
|
if (!desktop) {
|
||||||
|
@ -451,6 +452,16 @@ function checkScrollVideos() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function videoPreloadPosterDimensions(videoEl, posterUrl) {
|
||||||
|
var img = new Image();
|
||||||
|
img.onload = function () {
|
||||||
|
if (img.width > 0 && img.height > 0) {
|
||||||
|
videoEl.style.aspectRatio = img.width / img.height;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
img.src = posterUrl;
|
||||||
|
}
|
||||||
|
|
||||||
function isVisibleEnough(boxOffset, boxSize, viewOffset, viewSize, boxThreshold, viewThreshold) {
|
function isVisibleEnough(boxOffset, boxSize, viewOffset, viewSize, boxThreshold, viewThreshold) {
|
||||||
var boxEnd = boxOffset + boxSize;
|
var boxEnd = boxOffset + boxSize;
|
||||||
var viewEnd = viewOffset + viewSize;
|
var viewEnd = viewOffset + viewSize;
|
||||||
|
|
Loading…
Reference in a new issue