make Youtube under ur control
< Feedback on u-Youtube
大佬我使用人工智能提取了你的暂停缓冲功能,但是这个脚本有个问题,缓冲时不会考虑网络情况,只会一直往前跑进度,导致网络缓慢的时候不会缓存到视频。AI只能到这个样子了,无法解决问题。希望大佬抽空帮我改下,让脚本可以在缓存成功后才会继续向前缓冲。// ==UserScript==// @name 功夫制霸提取-暂停缓冲youtube// @namespace https://github.com/rasso1/u-Youtube// @version 1.46// @description 暂停缓冲youtube// @author ok!// @match https://www.youtube.com/watch?v=*// @run-at document-start// @grant GM_registerMenuCommand// ==/UserScript==let enableCache = false;document.addEventListener('keydown', function(e) { if(e.key === 'c') { enableCache = !enableCache; }});let currentTime = 0;let cacheSeconds = 30;let cacheInterval;GM_registerMenuCommand("Set Cache Seconds", () => { let seconds = prompt("Enter cache seconds:"); if(seconds) { cacheSeconds = parseInt(seconds); }});document.addEventListener('yt-page-data-updated', function() { let video = document.querySelector('video'); if (video) { video.addEventListener('pause', function() { if(!enableCache) return; currentTime = video.currentTime; video.currentTime += 0.1; cacheVideo(); }); video.addEventListener('play', function() { clearInterval(cacheInterval); if(currentTime > 0) { return; } currentTime = 0; }); function cacheVideo() { cacheInterval = setInterval(function() { if (video.currentTime >= video.duration) { clearInterval(cacheInterval); } else if (video.currentTime - currentTime >= cacheSeconds) { video.currentTime = currentTime; clearInterval(cacheInterval); } else { video.currentTime += 1; } }, 250); } }});
تسجيل الدخول إلى مرحلة ما بعد الرد.
大佬我使用人工智能提取了你的暂停缓冲功能,但是这个脚本有个问题,缓冲时不会考虑网络情况,只会一直往前跑进度,导致网络缓慢的时候不会缓存到视频。AI只能到这个样子了,无法解决问题。
希望大佬抽空帮我改下,让脚本可以在缓存成功后才会继续向前缓冲。
// ==UserScript==
// @name 功夫制霸提取-暂停缓冲youtube
// @namespace https://github.com/rasso1/u-Youtube
// @version 1.46
// @description 暂停缓冲youtube
// @author ok!
// @match https://www.youtube.com/watch?v=*
// @run-at document-start
// @grant GM_registerMenuCommand
// ==/UserScript==
let enableCache = false;
document.addEventListener('keydown', function(e) {
if(e.key === 'c') {
enableCache = !enableCache;
}
});
let currentTime = 0;
let cacheSeconds = 30;
let cacheInterval;
GM_registerMenuCommand("Set Cache Seconds", () => {
let seconds = prompt("Enter cache seconds:");
if(seconds) {
cacheSeconds = parseInt(seconds);
}
});
document.addEventListener('yt-page-data-updated', function() {
let video = document.querySelector('video');
if (video) {
video.addEventListener('pause', function() {
if(!enableCache) return;
currentTime = video.currentTime;
video.currentTime += 0.1;
cacheVideo();
});
video.addEventListener('play', function() {
clearInterval(cacheInterval);
if(currentTime > 0) {
return;
}
currentTime = 0;
});
function cacheVideo() {
cacheInterval = setInterval(function() {
if (video.currentTime >= video.duration) {
clearInterval(cacheInterval);
} else if (video.currentTime - currentTime >= cacheSeconds) {
video.currentTime = currentTime;
clearInterval(cacheInterval);
} else {
video.currentTime += 1;
}
}, 250);
}
}
});