1 import { VideoJSComponentInterface, videojsUntyped } from './peertube-videojs-typings'
3 const Button: VideoJSComponentInterface = videojsUntyped.getComponent('Button')
4 class PeerTubeLinkButton extends Button {
7 return this.buildElement()
11 const currentTime = Math.floor(this.player().currentTime())
12 this.el().setAttribute('href', this.buildHref(currentTime))
19 private buildElement () {
20 const el = videojsUntyped.dom.createEl('a', {
21 href: this.buildHref(),
22 innerHTML: 'PeerTube',
23 title: 'Go to the video page',
24 className: 'vjs-peertube-link',
28 el.addEventListener('mouseenter', () => this.updateHref())
33 private buildHref (time?: number) {
34 let href = window.location.href.replace('embed', 'watch')
36 if (window.location.search) href += '&start=' + time
37 else href += '?start=' + time
43 Button.registerComponent('PeerTubeLinkButton', PeerTubeLinkButton)