Greasy Fork is available in English.

Youtube - Resumer

Store video.currentTime locally

< 脚本Youtube - Resumer的反馈

评价:好评 - 脚本运行良好

dr4
§
发表于:2023-11-18

The script doesn't seem to work anymore

Dry Spoon作者
§
发表于:2023-11-19

I think I fixed it. There was an issue finding the video element.

Dry Spoon作者
§
发表于:2023-11-19

Never mind, it indeed doesn't work. Before, I just called document.querySelector('video') after a "yt-navigate-finish" event, but it stopped working like a week ago. I changed it to keep trying to find a video:

```
const observer = new MutationObserver((mutations, observer) => {
//Keep trying to find video
let video = document.querySelector('video')
if(video){
listen(video)
observer.disconnect() //video found
}
})

observer.observe(document, {childList:true, subtree:true})
```

Now it seems that the video found isn't the correct one.

Dry Spoon作者
§
发表于:2023-11-19

Just tried this and found 2 video elements. Not sure why this happens.

```
let videos = []

const observer = new MutationObserver((mutations, observer) => {
//Keep trying to find video
let video = document.querySelector('video')
if(video){
if(!videos.includes(video)){
videos.push(video)
}
listen(video)
//observer.disconnect() //video found
}
})
```

Dry Spoon作者
§
发表于:2023-11-19

Should be fixed. Changed the selector to document.querySelector('video.video-stream').

dr4
§
发表于:2023-11-20

Fixed, thanks

发表回复

登录以发表回复。