Skip to content

armgit / my-yt

Public Imported from GitHub
0

A clean and minimal youtube frontend, without all the ads and whistles

JavaScript

feat: when opening video externally, pause video

Christian Fei3cfd2add659f
diff --git a/client/components/video-element.js b/client/components/video-element.js
index fd67b98..59886c8 100644
--- a/client/components/video-element.js
+++ b/client/components/video-element.js
@@ -78,7 +78,7 @@ class VideoElement extends HTMLElement {
: !this.video.summary
? /*html*/`<span tabindex="0" class="action summarize" data-video-id="${this.video.id}">πŸ“– Summarize</span>`
: /*html*/`<span tabindex="0" class="action show-summary" data-video-id="${this.video.id}">πŸ“– Summary</span>`}
- <a href="https://www.youtube.com/watch?v=${this.video.id}" target="_blank">πŸ“Ί external</a>
+ <a href="https://www.youtube.com/watch?v=${this.video.id}" class="action open-externally" target="_blank">πŸ“Ί external</a>
</div>
`
@@ -90,6 +90,7 @@ class VideoElement extends HTMLElement {
addClickListener(this.querySelector('.action.summarize'), this.summarizeVideoHandler.bind(this))
addClickListener(this.querySelector('.action.show-summary'), this.showSummaryHandler.bind(this))
addClickListener(this.querySelector('.action.ignore'), this.toggleIgnoreVideoHandler.bind(this))
+ addClickListener(this.querySelector('.action.open-externally'), this.openExternallyHandler.bind(this))
addClickListener(this.querySelector('.channel-name'), this.filterByChannelHandler.bind(this))
addClickListener(this.querySelector('.play.video-placeholder'), this.watchVideoHandler.bind(this))
}
@@ -99,6 +100,7 @@ class VideoElement extends HTMLElement {
removeClickListener(this.querySelector('.action.summarize'), this.summarizeVideoHandler.bind(this))
removeClickListener(this.querySelector('.action.show-summary'), this.showSummaryHandler.bind(this))
removeClickListener(this.querySelector('.action.ignore'), this.toggleIgnoreVideoHandler.bind(this))
+ removeClickListener(this.querySelector('.action.open-externally'), this.openExternallyHandler.bind(this))
removeClickListener(this.querySelector('.channel-name'), this.filterByChannelHandler.bind(this))
removeClickListener(this.querySelector('.play.video-placeholder'), this.watchVideoHandler.bind(this))
this.querySelector('video') && this.unregisterVideoEvents(this.querySelector('video'))
@@ -198,6 +200,9 @@ class VideoElement extends HTMLElement {
this.render()
})
}
+ openExternallyHandler (event) {
+ this.querySelector('video') && this.querySelector('video').pause()
+ }
filterByChannelHandler (event) {
const $searchInput = document.querySelector('#search')
const channel = `@${this.video.channelName}`