From 3e653c03817998f1fdd0674be4ff9eea76091d56 Mon Sep 17 00:00:00 2001 From: 1bakedpotato <45945093+1bakedpotato@users.noreply.github.com> Date: Wed, 23 Oct 2019 17:49:01 -0500 Subject: [PATCH] Added: Ability to hide re-runs in sidebar channel lists (#687) --- .../modules/css_tweaks/index.js | 12 ++++++++++ src/sites/twitch-twilight/modules/layout.js | 22 +++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/src/sites/twitch-twilight/modules/css_tweaks/index.js b/src/sites/twitch-twilight/modules/css_tweaks/index.js index 17d6b50a..9b0929f1 100644 --- a/src/sites/twitch-twilight/modules/css_tweaks/index.js +++ b/src/sites/twitch-twilight/modules/css_tweaks/index.js @@ -19,6 +19,7 @@ const CLASSES = { 'side-closed-friends': '.side-nav--collapsed .online-friends', 'side-closed-rec-channels': '.side-nav--collapsed .recommended-channels,.side-nav--collapsed .ffz--popular-channels', 'side-offline-channels': '.side-nav-card__link[href*="/videos/"],.side-nav-card[href*="/videos/"]', + 'side-rerun-channels': '.side-nav .ffz--side-nav-card-rerun', 'prime-offers': '.top-nav__prime', @@ -133,6 +134,16 @@ export default class CSSTweaks extends Module { changed: val => this.toggleHide('side-offline-channels', val) }); + this.settings.add('layout.side-nav.hide-reruns', { + default: false, + ui: { + path: 'Appearance > Layout >> Side Navigation', + title: 'Hide Reruns', + component: 'setting-check-box' + }, + changed: val => this.toggleHide('side-rerun-channels', val) + }); + this.settings.add('layout.swap-sidebars', { default: false, ui: { @@ -282,6 +293,7 @@ export default class CSSTweaks extends Module { this.toggleHide('side-nav', !this.settings.get('layout.side-nav.show')); this.toggleHide('side-rec-friends', !this.settings.get('layout.side-nav.show-rec-friends')); this.toggleHide('side-offline-channels', this.settings.get('layout.side-nav.hide-offline')); + this.toggleHide('side-rerun-channels', this.settings.get('layout.side-nav.hide-reruns')); this.toggleHide('prime-offers', !this.settings.get('layout.prime-offers')); this.toggleHide('top-discover', !this.settings.get('layout.discover')); diff --git a/src/sites/twitch-twilight/modules/layout.js b/src/sites/twitch-twilight/modules/layout.js index a70ac13b..d8074854 100644 --- a/src/sites/twitch-twilight/modules/layout.js +++ b/src/sites/twitch-twilight/modules/layout.js @@ -35,6 +35,11 @@ export default class Layout extends Module { n => n.getPopularChannels && n.props && has(n.props, 'locale') ); + this.SideBarChannels = this.fine.define( + 'nav-cards', + t => t.getCardSlideInContent && t.props && has(t.props, 'tooltipContent') + ); + this.settings.add('layout.portrait', { default: false, ui: { @@ -179,6 +184,14 @@ export default class Layout extends Module { this.PopularChannels.on('mount', this.updatePopular, this); this.PopularChannels.on('update', this.updatePopular, this); + this.SideBarChannels.ready((cls, instances) => { + for(const inst of instances) + this.updateCardClass(inst); + }); + + this.SideBarChannels.on('mount', this.updateCardClass, this); + this.SideBarChannels.on('update', this.updateCardClass, this); + const t = this; this.RightColumn.ready((cls, instances) => { cls.prototype.ffzHideOnBreakpoint = function() { @@ -229,6 +242,15 @@ export default class Layout extends Module { return this.settings.get('layout.is-minimal') } + updateCardClass(inst) { + const node = this.fine.getChildNode(inst); + + if ( node ) + node.classList.toggle('ffz--side-nav-card-rerun', + inst.props?.tooltipContent?.props?.streamType === 'rerun' + ); + } + updateNavLinks() { for(const inst of this.TopNav.instances) try {