Fixed double binding for event listeners
This commit is contained in:
parent
d2dadb41c7
commit
3776b87d7e
@ -895,6 +895,7 @@ export default class AnimeNotifier {
|
||||
|
||||
// Once the video becomes visible, load it
|
||||
video["became visible"] = () => {
|
||||
if(!video["listeners attached"]) {
|
||||
// Prevent context menu
|
||||
video.addEventListener("contextmenu", e => e.preventDefault())
|
||||
|
||||
@ -919,7 +920,15 @@ export default class AnimeNotifier {
|
||||
let progressContainer = video.parentElement.getElementsByClassName("video-progress-container")[0]
|
||||
let timeElement = video.parentElement.getElementsByClassName("video-time")[0]
|
||||
|
||||
video.addEventListener("canplay", () => {
|
||||
video["playable"] = true
|
||||
})
|
||||
|
||||
video.addEventListener("timeupdate", () => {
|
||||
if(!video["playable"]) {
|
||||
return
|
||||
}
|
||||
|
||||
let time = video.currentTime
|
||||
let minutes = Math.trunc(time / 60)
|
||||
let seconds = Math.trunc(time) % 60
|
||||
@ -945,6 +954,9 @@ export default class AnimeNotifier {
|
||||
e.stopPropagation()
|
||||
})
|
||||
|
||||
video["listeners attached"] = true
|
||||
}
|
||||
|
||||
let modified = false
|
||||
|
||||
for(let child of video.children) {
|
||||
@ -962,6 +974,8 @@ export default class AnimeNotifier {
|
||||
}
|
||||
|
||||
if(modified) {
|
||||
video["playable"] = false
|
||||
|
||||
Diff.mutations.queue(() => {
|
||||
video.load()
|
||||
video.classList.add("element-found")
|
||||
|
Loading…
Reference in New Issue
Block a user