如何在 YouTube.com 视频 (javascript) 中触发鼠标悬停在视频上的动作?

How to trigger the mouse over video action in a YouTube.com video (javascript)?

对于我的 chrome 分机, 我正在尝试获取 YouTube 视频中的当前时间, 通过

工作
var timeArr = document.getElementsByTagName("ytp-time-current");  
  for (var i = 0; i < timeArr.length; i++) {
      var currentTime = priceEls[i].innerText;
  }

但只有当视频为 'focused' 时,浏览器才能看到时间戳,否则 HTML 不会更新以显示当前时间。

如何代表用户触发鼠标悬停效果?

您无需解析 UI 即可获取 YouTube 视频的时间。它是一个具有所有关联功能的 HTML5 <video> 元素,例如继承自 HTMLMediaElement:

let video = document.querySelector("video.html5-main-video");
let currentTime = video.currentTime; // Fractional, in seconds
let totalDuration = video.duration;