blob: b71b9a7af398fffa9da38a9400593ee0374e56a8 [file] [log] [blame]
Adrià Vilanova Martínez917797e2024-05-25 22:41:25 +02001import CssSelectorNodeWatcherScriptHandler from '../../../common/architecture/scripts/nodeWatcher/handlers/CssSelectorNodeWatcherScriptHandler';
2import { NodeMutation } from '../../../common/nodeWatcher/NodeWatcherHandler';
3import { isDarkThemeOn } from '../core/logic/darkTheme';
4import { unifiedProfilesFix } from '../core/logic/unifiedProfiles';
5import { CCDarkThemeNodeWatcherDependencies } from '../scripts/nodeWatcher.script';
6
7/**
8 * Redirect unified profile iframe to dark version if applicable
9 */
10export default class CCDarkThemeUnifiedProfilesIframeHandler extends CssSelectorNodeWatcherScriptHandler<CCDarkThemeNodeWatcherDependencies> {
11 cssSelector = 'iframe';
12
13 async onMutatedNode(mutation: NodeMutation) {
14 const optionsValues = await this.options.optionsProvider.getOptionsValues();
15
16 if (
17 isDarkThemeOn(optionsValues) &&
18 unifiedProfilesFix.checkIframe(mutation.node)
19 ) {
20 unifiedProfilesFix.fixIframe(mutation.node);
21 }
22 }
23}