Adrià Vilanova MartÃnez | 917797e | 2024-05-25 22:41:25 +0200 | [diff] [blame] | 1 | import CssSelectorNodeWatcherScriptHandler from '../../../common/architecture/scripts/nodeWatcher/handlers/CssSelectorNodeWatcherScriptHandler'; |
| 2 | import { NodeMutation } from '../../../common/nodeWatcher/NodeWatcherHandler'; |
| 3 | import { isDarkThemeOn } from '../core/logic/darkTheme'; |
| 4 | import { unifiedProfilesFix } from '../core/logic/unifiedProfiles'; |
| 5 | import { CCDarkThemeNodeWatcherDependencies } from '../scripts/nodeWatcher.script'; |
| 6 | |
| 7 | /** |
| 8 | * Redirect unified profile iframe to dark version if applicable |
| 9 | */ |
| 10 | export 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 | } |