Skip to content

armgit / my-yt

Public Imported from GitHub
0

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

JavaScript

chore: cleanup

Christian Fei6dcddc4c58a9
diff --git a/client/components/video-element.js b/client/components/video-element.js
index bbc5a90..69edabb 100644
--- a/client/components/video-element.js
+++ b/client/components/video-element.js
@@ -170,7 +170,6 @@ class VideoElement extends HTMLElement {
})
}
filterByChannelHandler (event) {
- // find search input, set value to channelname
const $searchInput = document.querySelector('#search')
if ($searchInput && $searchInput.value !== this.video.channelName) {
$searchInput.value = this.video.channelName
diff --git a/client/main.js b/client/main.js
index e9f11cc..b2671ff 100644
--- a/client/main.js
+++ b/client/main.js
@@ -149,6 +149,32 @@ const $closeSummary = $summary.querySelector("button")
$closeSummary.addEventListener("click", () => $summary.close())
$summary.addEventListener('close', () => {})
+
+observeDialogOpenPreventScroll($summary)
+
+function handleClick ($el, handler) {
+ if (!$el) return
+ $el.addEventListener('click', handler)
+ $el.addEventListener('keydown', (event) => event.key === 'Enter' && handler(event))
+}
+
+function observeDialogOpenPreventScroll (dialog) {
+ new MutationObserver((mutationList, observer) => {
+ for (const mutation of mutationList) {
+ if (mutation.type === "attributes" && mutation.attributeName === 'open') {
+ document.body.classList[mutation.target.open ? 'add' : 'remove']('dialog-opened')
+ }
+ }
+ }).observe(dialog, { attributes: true, childList: true, subtree: true })
+}
+
+function createVideoElement (video) {
+ const $video = document.createElement('video-element')
+ $video.dataset['data'] = JSON.stringify(video)
+ $video.dataset['videoId'] = video.id
+ return $video
+}
+
// settings ui
// const $showThumbnails = document.getElementById('show-thumbnails')
// $showThumbnails.addEventListener('click', (event) => {
@@ -181,23 +207,6 @@ $summary.addEventListener('close', () => {})
// applyShowThumbnails(store.get(store.showThumbnailsKey))
// applyIgnoredTerms(store.get(store.ignoreTermsKey))
-observeDialogOpenPreventScroll($summary)
-
-function handleClick ($el, handler) {
- if (!$el) return
- $el.addEventListener('click', handler)
- $el.addEventListener('keydown', (event) => event.key === 'Enter' && handler(event))
-}
-
-function observeDialogOpenPreventScroll (dialog) {
- new MutationObserver((mutationList, observer) => {
- for (const mutation of mutationList) {
- if (mutation.type === "attributes" && mutation.attributeName === 'open') {
- document.body.classList[mutation.target.open ? 'add' : 'remove']('dialog-opened')
- }
- }
- }).observe(dialog, { attributes: true, childList: true, subtree: true })
-}
// function applyShowThumbnails(showThumbnails) {
// if (showThumbnails) {
@@ -207,13 +216,4 @@ function observeDialogOpenPreventScroll (dialog) {
// }
// const $showThumbnailsCheckbox = document.getElementById('show-thumbnails')
// if ($showThumbnailsCheckbox) $showThumbnailsCheckbox.checked = showThumbnails
-// }
-
-function createVideoElement (video) {
- const $video = document.createElement('video-element')
- $video.dataset['data'] = JSON.stringify(video)
- $video.dataset['videoId'] = video.id
- return $video
-}
-
-window.createVideoElement = createVideoElement
+// }
\ No newline at end of file