A clean and minimal youtube frontend, without all the ads and whistles
JavaScript
fix: reorder ui elements
Seyar Chapukhe602f4ae8d06
diff --git a/client/components/video-element.js b/client/components/video-element.jsindex feace74..2798b9d 100644--- a/client/components/video-element.js+++ b/client/components/video-element.js@@ -46,32 +46,30 @@ class VideoElement extends HTMLElement {this.innerHTML = /*html*/`${this.video.downloaded- ? /*html*/`<div class="play video-placeholder" style="background-image: url(${this.video.thumbnail})"><div class="play-icon"></div></div>`- : /*html*/`<img title="Download video" class="download!" loading="lazy" src="${this.video.thumbnail}"/>`}+ ? /*html*/`<div class="video-wrapper"><div class="play video-placeholder" style="background-image: url(${this.video.thumbnail})"><div class="play-icon"></div></div><span class="info-duration">${this.video.duration || 'N/A'}</span></div>`+ : /*html*/`<div class="video-wrapper"><img title="Download video" class="download!" loading="lazy" src="${this.video.thumbnail}"/><span class="info-duration">${this.video.duration || 'N/A'}</span></div>`}<span class="action ignore" tabindex="0">${this.video.ignored ? 'unignore' : 'ignore'}</span>+ <h4 class="title">${this.video.title}</h4><div class="info"><span class="channel-name">${this.video.channelName}</span>- <br><div class="flex">- <span>${tryFormatDate(this.video.publishedAt)}</span><span>${this.video.viewCount}</span>- <span>${this.video.duration || 'N/A'}</span><br/>+ <span>${tryFormatDate(this.video.publishedAt)}</span></div></div>- <h4 class="title">${this.video.title}</h4><div class="actions flex">${this.video.downloaded? /*html*/`<span tabindex="0" class="action delete" data-video-id="${this.video.id}">ποΈ Delete</span>`: /*html*/`<span tabindex="0" class="action download" data-video-id="${this.video.id}">β¬οΈ Download</span>`}- ${store.get(store.useTLDWTubeKey) ?- /*html*/`<a target="_blank" href="https://tldw.tube/?v=${this.video.id}">π tldw.tube</a>`+ ${store.get(store.useTLDWTubeKey) ?+ /*html*/`<a target="_blank" href="https://tldw.tube/?v=${this.video.id}">π tldw.tube</a>`: !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></div>`-+this.registerEvents()}registerEvents () {@@ -117,7 +115,7 @@ class VideoElement extends HTMLElement {if (this.dataset['downloading'] === 'true') returnthis.dataset['downloading'] = 'true'-+let $downloadButton = event.target.classList.contains('.action') ? event.target : this.querySelector('.action.download')$downloadButton.innerText = this.downloadStartedText@@ -143,7 +141,7 @@ class VideoElement extends HTMLElement {this.querySelector('video') && this.unregisterVideoEvents(this.querySelector('video'))this.render()})- .catch((error) => console.error('Error deleting video:', error))+ .catch((error) => console.error('Error deleting video:', error))}summarizeVideoHandler (event) {event.preventDefault()@@ -177,7 +175,7 @@ class VideoElement extends HTMLElement {toggleIgnoreVideoHandler (event) {event.preventDefault()-+fetch('/api/ignore-video', {method: 'POST',headers: { 'Content-Type': 'application/json' },@@ -218,15 +216,15 @@ class VideoElement extends HTMLElement {scrollIntoViewWithOffset (offset, behavior = 'smooth') {const top = this.getBoundingClientRect().top - offset - document.body.getBoundingClientRect().topscrollTo({ top, behavior })- }+ }}customElements.define('video-element', VideoElement)function tryFormatDate(date) {try {- return new Date(date).toISOString().substring(0, 10)+ return new Date(date).toLocaleDateString(navigator.language || 'en-US').substring(0, 10)} catch (err) {return 'N/A'}-}\ No newline at end of file+}diff --git a/client/main.css b/client/main.cssindex 46f4d30..d739b32 100644--- a/client/main.css+++ b/client/main.css@@ -273,7 +273,7 @@ button:disabled, select:disabled, input[type="checkbox"]:disabled, input[type="rfont-weight: bold;padding: 5px;align-self: flex-start;- margin: 5px;+ margin: 5px 0 10px 0;user-select: none;-webkit-user-select: none;}@@ -289,7 +289,7 @@ button:disabled, select:disabled, input[type="checkbox"]:disabled, input[type="rcursor: pointer;}.video .title {- margin-top: 5px;+ margin-top: 7px;margin-bottom: 5px;min-height: 2rem;max-height: 2.5rem;@@ -328,12 +328,14 @@ button:disabled, select:disabled, input[type="checkbox"]:disabled, input[type="r.video .actions {font-size: 0.9rem;+ justify-content: space-between;+ margin-top: 10px;}+.video .actions > * {cursor: pointer;}-video-element, video-element video {transition: width 0.1s ease-in;}@@ -567,3 +569,37 @@ empty-state {.user-select-none {user-select: none;}++.video-wrapper {+ position: relative;+}++.info {+ display: flex;+ flex-wrap: wrap;+ color: var(--text-secondary);+ gap: 4px;+}++.info .channel-name {+ flex-basis: 100%;+}++.info .flex {+ justify-content: space-between;+ flex-basis: 100%;+}++.info .flex span:first-child {+ margin-left: 0;+}++.info-duration {+ position: absolute;+ bottom: 12px;+ right: 12px;+ background: var(--bg-primary);+ border-radius: 2px;+ padding: 2px 3px;+ opacity: 0.8;+}