保持YouTube控件始终可见 [英] keep youtube controls always visible
问题描述
我正在尝试创建一个Chrome扩展程序,以使控件始终在本机youtube页面中的youtube视频上始终可见.
i'm trying to make a chrome extension that keeps the controls always visible on a youtube video within the native youtube page.
到目前为止,我有这个js
so far i have this js
$(document).ready(function() {
setInterval(function(){
$('.ytp-autohide').removeClass('ytp-autohide');
$('#player-container').mouseover();
},100);
});
但是删除ytp-autohide类将停止计时器/栏进度,并且我无法弄清楚如何通过js mouseover或类似方法激活showcontrols函数.
but removing the ytp-autohide class stops the timer/bar progress and i cant figure out how to instead activate the showcontrols function via js mouseover or somesuch.
我可以保留进度栏吗?时间以某种方式还是用js重新创建mouseover showcontrols函数?
can i keep the progress bar & time going somehow or alternately recreate the mouseover showcontrols function with js?
推荐答案
那是:
setTimeout(function(){
let video = document.querySelector("#movie_player")
setInterval(function(){
video.dispatchEvent(new Event('mousemove'));
},100);
},1500)
因此,您没有针对正确的元素,并且没有正确触发事件.
So you where not targeting the right element and you where not triggering the event correctly.
这篇关于保持YouTube控件始终可见的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!