refactor: migrate CC dark theme feature to the new architecture

Bug: twpowertools:176
Change-Id: Iaea1015a788038a8a31acbdd33b267b551e0b6a1
diff --git a/src/features/ccDarkTheme/scripts/injectAutoDarkTheme.script.ts b/src/features/ccDarkTheme/scripts/injectAutoDarkTheme.script.ts
new file mode 100644
index 0000000..c462a03
--- /dev/null
+++ b/src/features/ccDarkTheme/scripts/injectAutoDarkTheme.script.ts
@@ -0,0 +1,17 @@
+import { ScriptPage } from '../../../common/architecture/scripts/Script';
+import StylesheetScript from '../../../common/architecture/scripts/stylesheet/StylesheetScript';
+
+export default class InjectAutoDarkTheme extends StylesheetScript {
+  stylesheet = 'ccDarkTheme.bundle.css';
+  attributes = { media: '(prefers-color-scheme: dark)' };
+  page = ScriptPage.CommunityConsole;
+
+  async shouldBeInjected(): Promise<boolean> {
+    const ccDarkThemeEnabled =
+      await this.optionsProvider.isEnabled('ccdarktheme');
+    const ccDarkThemeMode =
+      await this.optionsProvider.getOptionValue('ccdarktheme_mode');
+
+    return ccDarkThemeEnabled && ccDarkThemeMode === 'system';
+  }
+}