Adrià Vilanova Martínez | 6ecaa0d | 2024-10-26 17:04:32 +0200 | [diff] [blame] | 1 | import CssSelectorNodeWatcherHandler from '../../../infrastructure/presentation/nodeWatcher/handlers/CssSelectorHandler.adapter'; |
Adrià Vilanova Martínez | 43c7520 | 2024-10-19 15:55:15 +0200 | [diff] [blame] | 2 | import { NodeMutation } from '../../../presentation/nodeWatcher/NodeWatcherHandler'; |
Adrià Vilanova Martínez | 6ecaa0d | 2024-10-26 17:04:32 +0200 | [diff] [blame] | 3 | import { OptionsProviderPort } from '../../../services/options/OptionsProvider'; |
Adrià Vilanova Martínez | 917797e | 2024-05-25 22:41:25 +0200 | [diff] [blame] | 4 | import { isDarkThemeOn } from '../core/logic/darkTheme'; |
| 5 | import { unifiedProfilesFix } from '../core/logic/unifiedProfiles'; |
Adrià Vilanova Martínez | 917797e | 2024-05-25 22:41:25 +0200 | [diff] [blame] | 6 | |
| 7 | /** |
| 8 | * Redirect unified profile iframe to dark version if applicable |
| 9 | */ |
Adrià Vilanova Martínez | 6ecaa0d | 2024-10-26 17:04:32 +0200 | [diff] [blame] | 10 | export default class CCDarkThemeUnifiedProfilesIframeHandler extends CssSelectorNodeWatcherHandler { |
Adrià Vilanova Martínez | 917797e | 2024-05-25 22:41:25 +0200 | [diff] [blame] | 11 | cssSelector = 'iframe'; |
| 12 | |
Adrià Vilanova Martínez | 6ecaa0d | 2024-10-26 17:04:32 +0200 | [diff] [blame] | 13 | constructor(private optionsProvider: OptionsProviderPort) { |
| 14 | super(); |
| 15 | } |
| 16 | |
Adrià Vilanova Martínez | 917797e | 2024-05-25 22:41:25 +0200 | [diff] [blame] | 17 | async onMutatedNode(mutation: NodeMutation) { |
Adrià Vilanova Martínez | 6ecaa0d | 2024-10-26 17:04:32 +0200 | [diff] [blame] | 18 | const optionsValues = await this.optionsProvider.getOptionsValues(); |
Adrià Vilanova Martínez | 917797e | 2024-05-25 22:41:25 +0200 | [diff] [blame] | 19 | |
| 20 | if ( |
| 21 | isDarkThemeOn(optionsValues) && |
| 22 | unifiedProfilesFix.checkIframe(mutation.node) |
| 23 | ) { |
| 24 | unifiedProfilesFix.fixIframe(mutation.node); |
| 25 | } |
| 26 | } |
| 27 | } |