A clean and minimal youtube frontend, without all the ads and whistles
JavaScript
feat: use tldw.tube
Christian Feibf9f69408887
diff --git a/client/components/video-element.js b/client/components/video-element.jsindex 7e54c25..46b0665 100644--- a/client/components/video-element.js+++ b/client/components/video-element.js@@ -1,4 +1,7 @@import { addClickListener, removeClickListener } from "/lib/utils.js"+import Store from "/lib/store.js"+const store = new Store()+class VideoElement extends HTMLElement {constructor () {super()@@ -52,7 +55,9 @@ class VideoElement extends HTMLElement {${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>`}- ${!this.video.summary+ ${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>diff --git a/client/index.html b/client/index.htmlindex 2a7265c..41f5fd2 100644--- a/client/index.html+++ b/client/index.html@@ -75,6 +75,13 @@<div><small>Show the creators chosen thumbnail, or a neutral one based on the actual video frames</small></div></form><br>+ <form>+ <label for="use-tldw-tube">+ Use TLDW.tube for video summarization (opens externally)+ </label>+ <input type="checkbox" id="use-tldw-tube"/>+ </form>+ <br><manage-channels-form></manage-channels-form></div></template>diff --git a/client/lib/router.js b/client/lib/router.jsindex ba5a93c..b7863e8 100644--- a/client/lib/router.js+++ b/client/lib/router.js@@ -60,6 +60,13 @@ const routes = {$showOriginalThumbnail.addEventListener('click', (event) => {store.toggle(store.showOriginalThumbnailKey)})++ const $useTLDWTube = document.getElementById('use-tldw-tube')+ store.get(store.useTLDWTubeKey) ? $useTLDWTube.setAttribute('checked', 'true') : $useTLDWTube.removeAttribute('checked')++ $useTLDWTube.addEventListener('click', (event) => {+ store.toggle(store.useTLDWTubeKey)+ })} },'/404': { template: document.getElementById('not-found-template'), async initialize () {document.querySelector('search-videos #search').setAttribute('disabled', 'disabled')diff --git a/client/lib/store.js b/client/lib/store.jsindex 0580d5a..215347d 100644--- a/client/lib/store.js+++ b/client/lib/store.js@@ -2,6 +2,7 @@ export default class Store {showThumbnailsKey = 'showThumbnails'showBigPlayerKey = 'showBigPlayer'showOriginalThumbnailKey = 'showOriginalThumbnail'+ useTLDWTubeKey = 'useTLDWTube'lastVideosKey = 'lastVideos'ignoreTermsKey = 'ignoreTerms'@@ -9,16 +10,17 @@ export default class Store {if (!localStorage.getItem(this.showThumbnailsKey)) localStorage.setItem(this.showThumbnailsKey, 'true')if (!localStorage.getItem(this.showBigPlayerKey)) localStorage.setItem(this.showBigPlayerKey, 'true')if (!localStorage.getItem(this.showOriginalThumbnailKey)) localStorage.setItem(this.showOriginalThumbnailKey, 'false')+ if (!localStorage.getItem(this.useTLDWTubeKey)) localStorage.setItem(this.useTLDWTubeKey, 'false')if (!localStorage.getItem(this.lastVideosKey)) localStorage.setItem(this.lastVideosKey, '{}')if (!localStorage.getItem(this.ignoreTermsKey)) localStorage.setItem(this.ignoreTermsKey, '[]')}toggle (key) {- if (![this.showThumbnailsKey, this.showBigPlayerKey, this.showOriginalThumbnailKey].includes(key)) return console.error('invalid key', key)+ if (![this.showThumbnailsKey, this.showBigPlayerKey, this.showOriginalThumbnailKey, this.useTLDWTubeKey].includes(key)) return console.error('invalid key', key)localStorage.setItem(key, localStorage.getItem(key) === 'true' ? 'false' : 'true')}get(key) {- if (![this.showThumbnailsKey, this.showBigPlayerKey, this.showOriginalThumbnailKey, this.lastVideosKey, this.ignoreTermsKey].includes(key)) return console.error('invalid key', key)+ if (![this.showThumbnailsKey, this.showBigPlayerKey, this.showOriginalThumbnailKey, this.useTLDWTubeKey, this.lastVideosKey, this.ignoreTermsKey].includes(key)) return console.error('invalid key', key)return JSON.parse(localStorage.getItem(key))}set(key, value) {