blob: 28b97537ab15eecc3ec6f0ab2db9bedb550713c4 [file] [log] [blame]
import CssSelectorNodeWatcherHandler from '../../../infrastructure/presentation/nodeWatcher/handlers/CssSelectorHandler.adapter';
import { NodeMutation } from '../../../presentation/nodeWatcher/NodeWatcherHandler';
import { OptionsProviderPort } from '../../../services/options/OptionsProvider';
import { isDarkThemeOn } from '../core/logic/darkTheme';
import { unifiedProfilesFix } from '../core/logic/unifiedProfiles';
/**
* Redirect unified profile iframe to dark version if applicable
*/
export default class CCDarkThemeUnifiedProfilesIframeHandler extends CssSelectorNodeWatcherHandler {
cssSelector = 'iframe';
constructor(private optionsProvider: OptionsProviderPort) {
super();
}
async onMutatedNode(mutation: NodeMutation) {
const optionsValues = await this.optionsProvider.getOptionsValues();
if (
isDarkThemeOn(optionsValues) &&
unifiedProfilesFix.checkIframe(mutation.node)
) {
unifiedProfilesFix.fixIframe(mutation.node);
}
}
}