diff --git a/package.json b/package.json index c3e175b..10c0cae 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "yt-defaulter", "author": "GooseOb", - "version": "1.11.0-alpha.13", + "version": "1.11.0-alpha.14", "repository": { "type": "git", "url": "git+https://github.com/GooseOb/YT-Defaulter.git" diff --git a/src/index.ts b/src/index.ts index 8d976e1..d5c00d0 100644 --- a/src/index.ts +++ b/src/index.ts @@ -9,14 +9,11 @@ import * as get from './element-getters'; Object.assign(text, translations[document.documentElement.lang]); -if (config.update(config.value)) config.saveLS(config.value); - -const isMusicChannel = (aboveTheFold: HTMLElement) => - !!get.artistChannelBadge(aboveTheFold); - -const onPageChange = async () => { - if (location.pathname !== '/watch') return; +if (config.update(config.value)) { + config.saveLS(config.value); +} +const onVideoPage = async () => { const aboveTheFold = await untilAppear(get.aboveTheFold); config.channel.username = (await untilAppear(get.channelUsernameElementGetter(aboveTheFold))).href || @@ -24,11 +21,11 @@ const onPageChange = async () => { await plr.set(await untilAppear(get.plr)); - applySettings( - computeSettings( - config.value.flags.standardMusicSpeed && isMusicChannel(aboveTheFold) - ) - ); + const doNotChangeSpeed = + config.value.flags.standardMusicSpeed && + !!get.artistChannelBadge(aboveTheFold); + + applySettings(computeSettings(doNotChangeSpeed)); if (menu.value.element) { menu.controls.updateThisChannel(config.channel.get()); @@ -41,7 +38,9 @@ let lastHref: string; setInterval(() => { if (lastHref !== location.href) { lastHref = location.href; - setTimeout(onPageChange, 1_000); + if (location.pathname === '/watch') { + setTimeout(onVideoPage, 1_000); + } } }, 1_000);