2017-11-13 01:23:39 -05:00
'use strict' ;
// ============================================================================
// CSS Tweaks for Twitch Twilight
// ============================================================================
import Module from 'utilities/module' ;
import { ManagedStyle } from 'utilities/dom' ;
import { has } from 'utilities/object' ;
2021-09-06 16:48:48 -04:00
import { getFontsList , useFont } from 'utilities/fonts' ;
2017-11-13 01:23:39 -05:00
2019-09-26 20:34:37 -04:00
const STYLE _VALIDATOR = document . createElement ( 'span' ) ;
2017-11-13 01:23:39 -05:00
const CLASSES = {
2020-12-04 14:32:26 -05:00
//'unfollow': '.follow-btn__follow-btn--following,.follow-btn--following',
2019-09-27 15:44:33 -04:00
'top-discover' : '.navigation-link[data-a-target="discover-link"]' ,
2020-08-21 15:59:13 -04:00
'side-nav' : '.side-nav,#sideNav' ,
2021-01-27 17:36:01 -05:00
'side-nav-viewers' : '.side-nav-card__live-status' ,
2021-11-05 18:01:28 -04:00
'side-rec-channels' : '.side-nav .recommended-channels,.side-nav .side-nav-section + .side-nav-section:not(.online-friends):not(.bd--shelf)' ,
2020-07-10 20:08:29 -04:00
//'side-rec-friends': '.side-nav .recommended-friends',
2017-11-13 01:23:39 -05:00
'side-friends' : '.side-nav .online-friends' ,
'side-closed-friends' : '.side-nav--collapsed .online-friends' ,
2021-11-05 18:01:28 -04:00
'side-closed-rec-channels' : '.side-nav--collapsed .recommended-channels,.side-nav--collapsed .side-nav-section + .side-nav-section:not(.online-friends):not(.bd--shelf)' ,
2020-07-16 16:34:03 -04:00
'side-offline-channels' : '.ffz--side-nav-card-offline' ,
2019-10-23 17:49:01 -05:00
'side-rerun-channels' : '.side-nav .ffz--side-nav-card-rerun' ,
2021-05-19 16:59:26 -04:00
'modview-hide-info' : '.modview-player-widget__hide-stream-info' ,
2017-11-13 01:23:39 -05:00
2019-12-10 20:46:33 -05:00
'community-highlights' : '.community-highlight-stack__card' ,
2022-10-07 15:12:15 -04:00
'elevate-your-message' : '.chat-input__input-icons button[aria-label="ElevatedMessage"]' ,
2019-12-10 20:46:33 -05:00
2018-04-07 19:51:53 -04:00
'prime-offers' : '.top-nav__prime' ,
2021-11-05 18:01:28 -04:00
'discover-luna' : '.top-nav__external-link[data-a-target="try-presto-link"]' ,
2018-04-07 19:51:53 -04:00
2023-09-06 16:10:47 -04:00
'subtember' : '.subtember-gradient' ,
2021-08-16 17:23:12 -04:00
'player-gain-volume' : '.video-player__container[data-compressed="true"] .volume-slider__slider-container:not(.ffz--player-gain)' ,
2021-04-24 14:37:01 -04:00
2019-12-05 23:13:27 -05:00
'player-ext' : '.video-player .extension-taskbar,.video-player .extension-container,.video-player .extensions-dock__layout,.video-player .extensions-notifications,.video-player .extensions-video-overlay-size-container,.video-player .extensions-dock__layout' ,
2021-08-16 17:23:12 -04:00
'player-ext-hover' : '.video-player__container[data-controls="false"] .extension-taskbar,.video-player__container[data-controls="false"] .extension-container,.video-player__container[data-controls="false"] .extensions-dock__layout,.video-player__container[data-controls="false"] .extensions-notifications,.video-player__container[data-controls="false"] .extensions-video-overlay-size-container' ,
2017-11-15 22:01:15 -05:00
2018-12-18 03:46:33 -05:00
'player-event-bar' : '.channel-root .live-event-banner-ui__header' ,
2019-08-12 22:52:57 -04:00
'player-rerun-bar' : '.channel-root__player-container div.tw-c-text-overlay:not([data-a-target="hosting-ui-header"])' ,
2018-03-26 04:03:13 +02:00
2022-12-07 16:52:07 -05:00
'pinned-cheer' : '.pinned-cheer,.pinned-cheer-v2,.channel-leaderboard,.channel-leaderboard-marquee,div[data-test-selector="channel-leaderboard-container"]' ,
2020-09-15 19:17:29 -04:00
'whispers' : 'body .whispers-open-threads,.tw-core-button[data-a-target="whisper-box-button"],.whispers__pill' ,
2017-11-28 08:16:37 +01:00
2020-07-16 16:34:03 -04:00
'dir-live-ind' : '.live-channel-card[data-ffz-type="live"] .tw-channel-status-text-indicator, article[data-ffz-type="live"] .tw-channel-status-text-indicator' ,
2018-06-27 14:13:59 -04:00
'profile-hover' : '.preview-card .tw-relative:hover .ffz-channel-avatar' ,
2019-06-08 23:26:50 +02:00
'not-live-bar' : 'div[data-test-selector="non-live-video-banner-layout"]' ,
2021-03-11 14:25:34 -05:00
'channel-live-ind' : '.channel-header__user .tw-channel-status-text-indicator,.channel-info-content .tw-halo__indicator' ,
2020-07-02 18:19:41 -04:00
'celebration' : 'body .celebration__overlay' ,
2022-12-07 16:52:07 -05:00
'last-x-events' : '.last-x-events_container' ,
2023-06-26 13:11:27 -04:00
'pinned-hype-chat' : '.paid-pinned-chat-message-list' ,
2022-12-07 16:52:07 -05:00
'ci-mod-view' : '.chat-input__buttons-container a[href*="/moderator"]' ,
'ci-highlight-settings' : '.chat-input__buttons-container button[data-highlight-selector="chat-highlights-shortcut"]' ,
'ci-shield-mode' : '.chat-input__buttons-container > div:last-child button[class|="ScCoreButton"]:not([data-highlight-selector]):not([data-a-target])'
2017-11-13 01:23:39 -05:00
} ;
export default class CSSTweaks extends Module {
constructor ( ... args ) {
super ( ... args ) ;
this . should _enable = true ;
this . inject ( 'settings' ) ;
this . style = new ManagedStyle ;
this . chunks = { } ;
this . chunks _loaded = false ;
// Layout
2021-02-03 16:34:22 -05:00
this . settings . add ( 'metadata.modview.hide-info' , {
default : false ,
ui : {
path : 'Channel > Metadata >> Mod View' ,
title : 'Hide "Hide Stream Info Stripe" button.' ,
component : 'setting-check-box'
} ,
changed : val => this . toggleHide ( 'modview-hide-info' , val )
} ) ;
2020-07-14 15:20:09 -04:00
this . settings . add ( 'metadata.viewers.no-native' , {
requires : [ 'metadata.viewers' ] ,
default : null ,
process ( ctx , val ) {
return val == null ? ctx . get ( 'metadata.viewers' ) : val
} ,
changed : val => this . toggle ( 'hide-native-viewers' , val ) ,
ui : {
path : 'Channel > Metadata >> Player' ,
title : "Hide Twitch's native Viewer Count." ,
description : "By default, this is enabled whenever FFZ's own Viewer Count display is enabled to avoid redundant information." ,
component : 'setting-check-box'
}
} ) ;
2020-06-30 19:48:46 -04:00
this . settings . add ( 'metadata.uptime.no-native' , {
requires : [ 'metadata.uptime' ] ,
default : null ,
process ( ctx , val ) {
return val == null ? ctx . get ( 'metadata.uptime' ) !== 0 : val
} ,
changed : val => this . toggle ( 'hide-native-uptime' , val ) ,
ui : {
path : 'Channel > Metadata >> Player' ,
title : "Hide Twitch's native Stream Uptime." ,
description : "By default, this is enabled whenever FFZ's own Stream Uptime display is enabled to avoid redundant information." ,
component : 'setting-check-box'
}
} ) ;
2020-05-27 15:44:37 -04:00
this . settings . add ( 'layout.use-chat-fix' , {
2020-09-29 14:15:43 -04:00
requires : [ 'context.force_chat_fix' , 'layout.swap-sidebars' , 'layout.use-portrait' , 'chat.use-width' , 'context.isWatchParty' ] ,
2020-05-27 15:44:37 -04:00
process ( ctx ) {
2020-09-29 14:15:43 -04:00
if ( ctx . get ( 'context.isWatchParty' ) )
return false ;
2020-07-02 14:54:46 -04:00
return ctx . get ( 'context.force_chat_fix' ) || ctx . get ( 'layout.swap-sidebars' ) || ctx . get ( 'layout.use-portrait' ) || ctx . get ( 'chat.use-width' )
2020-05-27 15:44:37 -04:00
} ,
changed : val => {
2020-07-02 14:54:46 -04:00
if ( val )
this . toggle ( 'chat-no-animate' , true ) ;
else if ( ! val && ! this . _no _anim _timer )
this . _no _anim _timer = requestAnimationFrame ( ( ) => {
this . _no _anim _timer = null ;
if ( ! this . settings . get ( 'layout.use-chat-fix' ) )
this . toggle ( 'chat-no-animate' , false ) ;
} ) ;
2020-05-27 15:44:37 -04:00
this . toggle ( 'chat-fix' , val ) ;
this . emit ( 'site.player:fix-player' ) ;
2020-10-16 15:19:11 -04:00
this . emit ( 'site.layout:resize' ) ;
2020-05-27 15:44:37 -04:00
}
} ) ;
2017-11-13 01:23:39 -05:00
this . settings . add ( 'layout.side-nav.show' , {
2020-07-16 16:34:03 -04:00
default : 1 ,
requires : [ 'layout.use-portrait' ] ,
process ( ctx , val ) {
if ( val === 2 )
return ! ctx . get ( 'layout.use-portrait' ) ;
return val ;
} ,
2017-11-13 01:23:39 -05:00
ui : {
sort : - 1 ,
path : 'Appearance > Layout >> Side Navigation' ,
title : 'Display Side Navigation' ,
2020-07-16 16:34:03 -04:00
component : 'setting-select-box' ,
data : [
{ value : 0 , title : 'Never' } ,
{ value : 1 , title : 'Always' } ,
{ value : 2 , title : 'Hide in Portrait' }
]
2017-11-13 01:23:39 -05:00
} ,
2020-07-16 16:34:03 -04:00
2020-11-14 14:08:27 -05:00
changed : val => {
this . toggle ( 'hide-side-nav' , ! val ) ;
this . emit ( 'site.layout:resize' ) ;
}
2017-11-13 01:23:39 -05:00
} ) ;
2021-01-27 17:36:01 -05:00
this . settings . add ( 'layout.side-nav.hide-viewers' , {
default : false ,
ui : {
path : 'Appearance > Layout >> Side Navigation' ,
title : 'Hide Channel View Counts' ,
component : 'setting-check-box'
} ,
changed : val => this . toggleHide ( 'side-nav-viewers' , val )
} ) ;
2018-07-24 13:52:11 -04:00
this . settings . add ( 'layout.side-nav.show-avatars' , {
default : true ,
ui : {
path : 'Appearance > Layout >> Side Navigation' ,
title : 'Display Channel Avatars' ,
component : 'setting-check-box'
} ,
changed : val => this . toggle ( 'hide-side-nav-avatars' , ! val )
} ) ;
2017-11-13 01:23:39 -05:00
this . settings . add ( 'layout.side-nav.show-rec-channels' , {
default : 1 ,
ui : {
path : 'Appearance > Layout >> Side Navigation' ,
2019-06-06 16:33:14 -04:00
title : 'Display Recommended / Popular Channels' ,
2017-11-13 01:23:39 -05:00
component : 'setting-select-box' ,
data : [
{ value : 0 , title : 'Never' } ,
{ value : 1 , title : 'Always' } ,
{ value : 2 , title : 'When Side Navigation is Open' }
]
} ,
changed : val => {
this . toggleHide ( 'side-rec-channels' , val === 0 ) ;
this . toggleHide ( 'side-closed-rec-channels' , val === 2 ) ;
}
} ) ;
this . settings . add ( 'layout.side-nav.show-friends' , {
default : 1 ,
ui : {
path : 'Appearance > Layout >> Side Navigation' ,
title : 'Display Online Friends' ,
component : 'setting-select-box' ,
data : [
{ value : 0 , title : 'Never' } ,
{ value : 1 , title : 'Always' } ,
{ value : 2 , title : 'When Side Navigation is Open' }
]
} ,
changed : val => {
this . toggleHide ( 'side-friends' , val === 0 ) ;
this . toggleHide ( 'side-closed-friends' , val === 2 ) ;
}
} ) ;
2020-07-10 20:08:29 -04:00
/ * t h i s . s e t t i n g s . a d d ( ' l a y o u t . s i d e - n a v . s h o w - r e c - f r i e n d s ' , {
2017-11-13 01:23:39 -05:00
default : true ,
ui : {
path : 'Appearance > Layout >> Side Navigation' ,
title : 'Display Recommended Friends' ,
component : 'setting-check-box'
} ,
changed : val => this . toggleHide ( 'side-rec-friends' , ! val )
2020-07-10 20:08:29 -04:00
} ) ; * /
2017-11-13 01:23:39 -05:00
2020-07-10 20:08:29 -04:00
this . settings . add ( 'layout.side-nav.hide-offline' , {
2017-11-13 01:23:39 -05:00
default : false ,
ui : {
2018-04-07 19:51:53 -04:00
path : 'Appearance > Layout >> Side Navigation' ,
2019-03-26 17:37:00 -04:00
title : 'Hide Offline Channels' ,
2017-11-13 01:23:39 -05:00
component : 'setting-check-box'
} ,
2019-03-26 17:37:00 -04:00
changed : val => this . toggleHide ( 'side-offline-channels' , val )
2020-07-10 20:08:29 -04:00
} ) ;
2017-11-13 01:23:39 -05:00
2019-10-23 19:30:27 -04:00
this . settings . add ( 'layout.side-nav.rerun-style' , {
default : 1 ,
2019-10-23 17:49:01 -05:00
ui : {
path : 'Appearance > Layout >> Side Navigation' ,
2019-10-23 19:30:27 -04:00
title : 'Display Reruns' ,
component : 'setting-select-box' ,
data : [
{ value : 0 , title : 'Do Not Display' } ,
{ value : 1 , title : 'Normally' } ,
{ value : 2 , title : 'Faded (33% Opacity)' }
]
2019-10-23 17:49:01 -05:00
} ,
2019-10-23 19:30:27 -04:00
changed : val => {
this . toggleHide ( 'side-rerun-channels' , val === 0 ) ;
this . toggle ( 'side-rerun-opacity' , val === 2 ) ;
}
2019-10-23 17:49:01 -05:00
} ) ;
2019-03-26 17:37:00 -04:00
this . settings . add ( 'layout.swap-sidebars' , {
2019-03-26 17:31:40 -04:00
default : false ,
2020-09-29 14:15:43 -04:00
requires : [ 'context.isWatchParty' ] ,
process ( ctx , val ) {
return ctx . get ( 'context.isWatchParty' ) ? false : val ;
} ,
2019-03-26 17:31:40 -04:00
ui : {
path : 'Appearance > Layout >> Side Navigation' ,
2019-03-26 17:37:00 -04:00
title : 'Swap Sidebars' ,
description : 'Swap navigation and chat to the opposite sides of the window.' ,
2019-03-26 17:31:40 -04:00
component : 'setting-check-box'
} ,
2020-10-16 15:19:11 -04:00
changed : val => {
this . toggle ( 'swap-sidebars' , val ) ;
this . emit ( 'site.layout:resize' ) ;
}
2019-03-26 17:31:40 -04:00
} ) ;
2017-11-13 01:23:39 -05:00
this . settings . add ( 'layout.minimal-navigation' , {
2020-10-14 14:55:10 -04:00
requires : [ 'layout.theatre-navigation' , 'context.isWatchParty' ] ,
2017-11-13 01:23:39 -05:00
default : false ,
2018-04-07 19:51:53 -04:00
process ( ctx , val ) {
2020-10-14 14:55:10 -04:00
if ( ctx . get ( 'context.isWatchParty' ) )
return false ;
2018-04-07 19:51:53 -04:00
return ctx . get ( 'layout.theatre-navigation' ) ?
true : val ;
} ,
2017-11-13 01:23:39 -05:00
ui : {
2018-04-07 19:51:53 -04:00
path : 'Appearance > Layout >> Top Navigation' ,
2017-11-13 01:23:39 -05:00
title : 'Minimize Navigation' ,
description : "Slide the site navigation bar up out of view when it isn't in use." ,
component : 'setting-check-box'
} ,
2020-10-16 15:19:11 -04:00
changed : val => {
this . toggle ( 'minimal-navigation' , val ) ;
this . emit ( 'site.layout:resize' ) ;
}
2017-11-13 01:23:39 -05:00
} ) ;
2018-04-07 19:51:53 -04:00
this . settings . add ( 'layout.theatre-navigation' , {
requires : [ 'context.ui.theatreModeEnabled' ] ,
default : false ,
process ( ctx , val ) {
return ctx . get ( 'context.ui.theatreModeEnabled' ) ? val : false
} ,
ui : {
path : 'Appearance > Layout >> Top Navigation' ,
title : 'Show the minimized navigation bar when in theatre mode.' ,
component : 'setting-check-box'
} ,
2020-10-16 15:19:11 -04:00
changed : val => {
this . toggle ( 'theatre-nav' , val ) ;
this . emit ( 'site.layout:resize' ) ;
}
2019-03-14 21:43:44 -04:00
} ) ;
2023-09-06 16:10:47 -04:00
this . settings . add ( 'layout.subtember' , {
default : true ,
ui : {
path : 'Appearance > Layout >> Channel' ,
title : 'Allow the Subtember upsell banner to appear.' ,
component : 'setting-check-box'
}
} ) ;
2019-03-14 21:43:44 -04:00
this . settings . add ( 'layout.discover' , {
default : true ,
ui : {
path : 'Appearance > Layout >> Top Navigation' ,
title : 'Show Discover link.' ,
component : 'setting-check-box'
} ,
2019-09-28 23:52:50 -04:00
changed : val => {
this . toggleHide ( 'top-discover' , ! val ) ;
this . updateTopNav ( ) ;
}
2019-03-14 21:43:44 -04:00
} ) ;
2018-04-07 19:51:53 -04:00
this . settings . add ( 'layout.prime-offers' , {
default : true ,
ui : {
path : 'Appearance > Layout >> Top Navigation' ,
2020-10-14 14:55:10 -04:00
title : 'Show Prime Gaming Loot.' ,
2018-04-07 19:51:53 -04:00
component : 'setting-check-box'
} ,
changed : val => this . toggleHide ( 'prime-offers' , ! val )
} ) ;
2021-11-05 18:01:28 -04:00
this . settings . add ( 'layout.hide-discover-luna' , {
default : false ,
ui : {
path : 'Appearance > Layout >> Top Navigation' ,
title : 'Hide the "Discover Luna" link.' ,
component : 'setting-check-box'
} ,
changed : val => this . toggleHide ( 'discover-luna' , val )
} ) ;
2017-11-13 01:23:39 -05:00
// Chat
this . settings . add ( 'whispers.show' , {
default : true ,
ui : {
path : 'Chat > Whispers >> General' ,
title : 'Display Whispers' ,
component : 'setting-check-box'
} ,
2020-10-16 15:19:11 -04:00
changed : val => {
this . toggleHide ( 'whispers' , ! val ) ;
this . emit ( 'site.layout:resize' ) ;
}
2017-11-13 01:23:39 -05:00
} ) ;
2023-06-26 13:11:27 -04:00
this . settings . add ( 'chat.hype.show-pinned' , {
default : true ,
ui : {
path : 'Chat > Hype Chat >> Appearance' ,
title : 'Allow Hype Chat messages to appear pinned at the top of chat.' ,
component : 'setting-check-box'
} ,
changed : val => this . toggleHide ( 'pinned-hype-chat' , ! val )
} ) ;
2017-11-13 01:23:39 -05:00
this . settings . add ( 'chat.bits.show' , {
default : true ,
ui : {
order : - 1 ,
path : 'Chat > Bits and Cheering >> Appearance' ,
title : 'Display Bits' ,
description : 'Display UI associated with bits. Note: This will not hide cheering in chat messages.' ,
component : 'setting-check-box'
} ,
changed : val => this . toggle ( 'hide-bits' , ! val )
} ) ;
2019-05-29 16:35:09 -04:00
// Other?
2020-04-13 18:12:33 -04:00
this . settings . add ( 'channel.show-celebrations' , {
default : true ,
ui : {
path : 'Channel > Appearance >> General' ,
title : 'Allow Celebrations to appear.' ,
description : 'Celebrations are animations that cover the entire Twitch page.' ,
component : 'setting-check-box'
} ,
changed : val => this . toggleHide ( 'celebration' , ! val )
} ) ;
2019-09-26 20:34:37 -04:00
this . settings . add ( 'layout.theme.global-font' , {
default : '' ,
ui : {
path : 'Appearance > Theme >> Fonts' ,
title : 'Font Family' ,
2021-09-06 16:48:48 -04:00
description : 'Override the font used for the entire Twitch website. The old default font was: `"Helvetica Neue",Helvetica,Arial,sans-serif`\n\nAny font available via [Google Fonts](https://fonts.google.com/) can be loaded by prefixing the font name with `google:`.' ,
component : 'setting-combo-box' ,
data : ( ) => getFontsList ( )
2019-09-26 20:34:37 -04:00
} ,
changed : ( ) => this . updateFont ( )
} ) ;
2020-07-23 16:00:00 -04:00
this . settings . add ( 'channel.hide-unfollow' , {
default : false ,
ui : {
path : 'Channel > Appearance >> General' ,
title : 'Hide the Unfollow button.' ,
component : 'setting-check-box'
} ,
2020-12-04 20:03:01 +01:00
changed : val => this . toggle ( 'hide-unfollow-button' , val )
2020-07-23 16:00:00 -04:00
} ) ;
2019-06-17 15:32:38 -04:00
this . settings . add ( 'channel.hide-live-indicator' , {
requires : [ 'context.route.name' ] ,
process ( ctx , val ) {
2020-07-26 17:50:14 -04:00
return ( ctx . get ( 'context.route.name' ) === 'user' || ctx . get ( 'context.route.name' ) === 'user-home' ) ? val : false
2019-06-17 15:32:38 -04:00
} ,
default : false ,
ui : {
path : 'Channel > Appearance >> General' ,
title : 'Hide the "LIVE" indicator on live channel pages.' ,
component : 'setting-check-box'
} ,
changed : val => this . toggleHide ( 'channel-live-ind' , val )
} ) ;
2019-05-29 16:35:09 -04:00
this . settings . add ( 'channel.round-avatars' , {
default : true ,
ui : {
path : 'Channel > Appearance >> General' ,
title : 'Allow avatar images to be rounded.' ,
component : 'setting-check-box'
} ,
changed : val => this . toggle ( 'square-avatars' , ! val )
} ) ;
2019-06-08 23:26:50 +02:00
2020-07-23 16:00:00 -04:00
/ * t h i s . s e t t i n g s . a d d ( ' c h a n n e l . h i d e - n o t - l i v e - b a r ' , {
2019-06-17 15:32:38 -04:00
default : false ,
2019-06-08 23:26:50 +02:00
ui : {
path : 'Channel > Appearance >> General' ,
2020-05-27 16:52:44 -03:00
title : 'Hide the "Now Live" bar.' ,
2019-06-08 17:35:48 -04:00
description : 'Hide the bar which appears beneath clips and videos when the streamer is live, telling you they are live.' ,
2019-06-08 23:26:50 +02:00
component : 'setting-check-box'
} ,
2019-06-08 17:35:48 -04:00
changed : val => this . toggleHide ( 'not-live-bar' , val )
2020-07-23 16:00:00 -04:00
} ) ; * /
2017-11-13 01:23:39 -05:00
}
onEnable ( ) {
2021-02-03 16:34:22 -05:00
this . toggleHide ( 'modview-hide-info' , this . settings . get ( 'metadata.modview.hide-info' ) ) ;
2021-01-27 17:36:01 -05:00
this . toggleHide ( 'side-nav-viewers' , this . settings . get ( 'layout.side-nav.hide-viewers' ) ) ;
2020-06-30 19:48:46 -04:00
this . toggle ( 'hide-native-uptime' , this . settings . get ( 'metadata.uptime.no-native' ) ) ;
2020-07-14 15:20:09 -04:00
this . toggle ( 'hide-native-viewers' , this . settings . get ( 'metadata.viewers.no-native' ) ) ;
2020-05-27 15:44:37 -04:00
this . toggle ( 'chat-fix' , this . settings . get ( 'layout.use-chat-fix' ) ) ;
2017-11-13 01:23:39 -05:00
this . toggle ( 'swap-sidebars' , this . settings . get ( 'layout.swap-sidebars' ) ) ;
this . toggle ( 'minimal-navigation' , this . settings . get ( 'layout.minimal-navigation' ) ) ;
2018-04-07 19:51:53 -04:00
this . toggle ( 'theatre-nav' , this . settings . get ( 'layout.theatre-navigation' ) ) ;
2017-11-13 01:23:39 -05:00
2018-07-24 13:52:11 -04:00
this . toggle ( 'hide-side-nav-avatars' , ! this . settings . get ( 'layout.side-nav.show-avatars' ) ) ;
2019-12-05 23:13:27 -05:00
this . toggle ( 'hide-side-nav' , ! this . settings . get ( 'layout.side-nav.show' ) ) ;
2020-07-10 20:08:29 -04:00
//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' ) ) ;
2021-11-05 18:01:28 -04:00
this . toggleHide ( 'discover-luna' , this . settings . get ( 'layout.hide-discover-luna' ) ) ;
2018-04-07 19:51:53 -04:00
this . toggleHide ( 'prime-offers' , ! this . settings . get ( 'layout.prime-offers' ) ) ;
2019-03-14 21:43:44 -04:00
this . toggleHide ( 'top-discover' , ! this . settings . get ( 'layout.discover' ) ) ;
2020-12-04 20:03:01 +01:00
this . toggle ( 'hide-unfollow-button' , this . settings . get ( 'channel.hide-unfollow' ) ) ;
2017-11-13 01:23:39 -05:00
2023-06-26 13:11:27 -04:00
this . toggleHide ( 'pinned-hype-chat' , ! this . settings . get ( 'chat.hype.show-pinned' ) ) ;
2019-05-29 16:35:09 -04:00
this . toggle ( 'square-avatars' , ! this . settings . get ( 'channel.round-avatars' ) ) ;
2020-07-23 16:00:00 -04:00
//this.toggleHide('not-live-bar', this.settings.get('channel.hide-not-live-bar'));
2019-06-17 15:32:38 -04:00
this . toggleHide ( 'channel-live-ind' , this . settings . get ( 'channel.hide-live-indicator' ) ) ;
2019-05-29 16:35:09 -04:00
2019-10-23 19:30:27 -04:00
const reruns = this . settings . get ( 'layout.side-nav.rerun-style' ) ;
this . toggleHide ( 'side-rerun-channels' , reruns === 0 ) ;
this . toggle ( 'side-rerun-opacity' , reruns === 2 ) ;
2017-11-13 01:23:39 -05:00
const recs = this . settings . get ( 'layout.side-nav.show-rec-channels' ) ;
this . toggleHide ( 'side-rec-channels' , recs === 0 ) ;
this . toggleHide ( 'side-closed-rec-channels' , recs === 2 ) ;
const friends = this . settings . get ( 'layout.side-nav.show-friends' ) ;
this . toggleHide ( 'side-friends' , friends === 0 ) ;
this . toggleHide ( 'side-closed-friends' , friends === 2 ) ;
this . toggleHide ( 'whispers' , ! this . settings . get ( 'whispers.show' ) ) ;
2020-04-13 18:12:33 -04:00
this . toggleHide ( 'celebration' , ! this . settings . get ( 'channel.show-celebrations' ) ) ;
2019-09-26 20:34:37 -04:00
2023-09-06 16:10:47 -04:00
this . settings . getChanges ( 'layout.subtember' , val => this . toggleHide ( 'subtember' , ! val ) ) ;
2019-09-26 20:34:37 -04:00
this . updateFont ( ) ;
2019-09-28 23:52:50 -04:00
this . updateTopNav ( ) ;
2020-05-27 15:44:37 -04:00
this . emit ( 'site.player:fix-player' ) ;
2020-10-16 15:19:11 -04:00
this . emit ( 'site.layout:resize' ) ;
2019-09-28 23:52:50 -04:00
}
updateTopNav ( ) {
requestAnimationFrame ( ( ) => this . emit ( 'site.layout:update-nav' ) ) ;
2019-09-26 20:34:37 -04:00
}
updateFont ( ) {
let font = this . settings . get ( 'layout.theme.global-font' ) ;
if ( font && font . length ) {
2021-09-06 16:48:48 -04:00
const [ processed , unloader ] = useFont ( font ) ;
font = processed ;
if ( this . _font _unloader )
this . _font _unloader ( ) ;
this . _font _unloader = unloader ;
2019-09-26 20:34:37 -04:00
if ( font . indexOf ( ' ' ) !== - 1 && font . indexOf ( ',' ) === - 1 && font . indexOf ( '"' ) === - 1 && font . indexOf ( "'" ) === - 1 )
font = ` " ${ font } " ` ;
STYLE _VALIDATOR . style . fontFamily = '' ;
STYLE _VALIDATOR . style . fontFamily = font ;
if ( STYLE _VALIDATOR . style . fontFamily ) {
this . setVariable ( 'global-font' , font ) ;
this . toggle ( 'global-font' , true ) ;
return ;
}
}
this . toggle ( 'global-font' , false ) ;
this . deleteVariable ( 'global-font' ) ;
2018-08-03 15:25:50 -04:00
}
2017-11-13 01:23:39 -05:00
toggleHide ( key , val ) {
const k = ` hide-- ${ key } ` ;
if ( ! val ) {
this . style . delete ( k ) ;
return ;
}
if ( ! has ( CLASSES , key ) )
throw new Error ( ` cannot find class for " ${ key } " ` ) ;
this . style . set ( k , ` ${ CLASSES [ key ] } { display: none !important } ` ) ;
}
async toggle ( key , val ) {
if ( ! val ) {
this . style . delete ( key ) ;
return ;
}
if ( ! this . chunks _loaded )
await this . populate ( ) ;
if ( ! has ( this . chunks , key ) )
throw new Error ( ` cannot find chunk " ${ key } " ` ) ;
this . style . set ( key , this . chunks [ key ] ) ;
}
2017-11-17 14:59:46 -05:00
set ( key , val ) { return this . style . set ( key , val ) }
delete ( key ) { return this . style . delete ( key ) }
setVariable ( key , val , scope = 'body' ) {
this . style . set ( ` var-- ${ key } ` , ` ${ scope } { --ffz- ${ key } : ${ val } ; } ` ) ;
}
deleteVariable ( key ) { this . style . delete ( ` var-- ${ key } ` ) }
2017-11-13 01:23:39 -05:00
populate ( ) {
if ( this . chunks _loaded )
return ;
return new Promise ( async r => {
const raw = ( await import ( /* webpackChunkName: "site-css-tweaks" */ './styles.js' ) ) . default ;
for ( const key of raw . keys ( ) ) {
const k = key . slice ( 2 , key . length - ( key . endsWith ( '.scss' ) ? 5 : 4 ) ) ;
2019-06-19 20:57:14 -04:00
this . chunks [ k ] = raw ( key ) . default ;
2017-11-13 01:23:39 -05:00
}
2020-10-28 17:09:37 -04:00
this . emit ( 'site.layout:resize' ) ;
2017-11-13 01:23:39 -05:00
this . chunks _loaded = true ;
r ( ) ;
} )
}
2020-05-27 16:52:44 -03:00
}