11/** biome-ignore-all lint/complexity/noExcessiveCognitiveComplexity: allow it */
2- import styleText from ' data-text:./index.css' ;
3- import { serverToClient } from ' @lgamila/shared' ;
4- import { Storage } from ' @plasmohq/storage' ;
5- import type { PlasmoCSConfig , PlasmoGetStyle } from ' plasmo' ;
6- import { useCallback , useEffect , useState } from ' react' ;
7- import { NotificationCard } from ' ./components/molecules/notification-card' ;
8- import { playNotificationSound } from ' ./lib/audio' ;
9- import { API_URL , NOTIFICATION_DURATION } from ' ./lib/constants' ;
10- import { logger } from ' ./lib/logger' ;
11- import type { Settings , Streamer } from ' ./lib/types' ;
2+ import styleText from " data-text:./index.css" ;
3+ import { serverToClient } from " @lgamila/shared" ;
4+ import { Storage } from " @plasmohq/storage" ;
5+ import type { PlasmoCSConfig , PlasmoGetStyle } from " plasmo" ;
6+ import { useCallback , useEffect , useState } from " react" ;
7+ import { NotificationCard } from " ./components/molecules/notification-card" ;
8+ import { playNotificationSound } from " ./lib/audio" ;
9+ import { API_URL , NOTIFICATION_DURATION } from " ./lib/constants" ;
10+ import { logger } from " ./lib/logger" ;
11+ import type { Settings , Streamer } from " ./lib/types" ;
1212
1313interface StreamerData {
1414 name : string ;
@@ -18,7 +18,7 @@ interface StreamerData {
1818}
1919
2020export const config : PlasmoCSConfig = {
21- matches : [ ' https://*.twitch.tv/*' , ' https://*.kick.com/*' ] ,
21+ matches : [ " https://*.twitch.tv/*" , " https://*.kick.com/*" ] ,
2222 all_frames : true ,
2323} ;
2424
@@ -27,7 +27,7 @@ const CHECK_INTERVAL = 10_000;
2727
2828const getStreamer = async (
2929 name : string ,
30- platform : ' twitch' | ' kick'
30+ platform : " twitch" | " kick"
3131) : Promise < Streamer [ ] > => {
3232 const response = await fetch (
3333 `${ API_URL } /api/streamers?search=${ name } &platform=${ platform } `
@@ -40,10 +40,10 @@ const getStreamer = async (
4040} ;
4141
4242const determinePlatform = ( url : string ) => {
43- if ( url . includes ( ' twitch.tv' ) ) {
44- return ' twitch' as const ;
43+ if ( url . includes ( " twitch.tv" ) ) {
44+ return " twitch" as const ;
4545 }
46- return ' kick' as const ;
46+ return " kick" as const ;
4747} ;
4848
4949const TWITCH_URL_REGEX =
@@ -110,7 +110,7 @@ const checkAndRedirect = async () => {
110110 currentStreamerData . livePlatforms ?. [ 0 ] ??
111111 currentStreamerData . livePlatform ;
112112 const username =
113- platform === ' twitch'
113+ platform === " twitch"
114114 ? currentStreamerData . twitchUsername
115115 : currentStreamerData . kickUsername ;
116116 window . location . href = `https://www.${ platform } .com/${ username } ` ;
@@ -122,7 +122,7 @@ let checkInterval: number | null = null;
122122
123123const startChecking = ( ) => {
124124 if ( checkInterval ) return ;
125- logger . info ( ' Starting auto-redirect checks' ) ;
125+ logger . info ( " Starting auto-redirect checks" ) ;
126126 checkAndRedirect ( ) ; // Initial check
127127 checkInterval = setInterval (
128128 checkAndRedirect ,
@@ -132,7 +132,7 @@ const startChecking = () => {
132132
133133const stopChecking = ( ) => {
134134 if ( ! checkInterval ) return ;
135- logger . info ( ' Stopping auto-redirect checks' ) ;
135+ logger . info ( " Stopping auto-redirect checks" ) ;
136136 clearInterval ( checkInterval ) ;
137137 checkInterval = null ;
138138} ;
@@ -152,16 +152,16 @@ storage.watch({
152152} ) ;
153153
154154// Initial setup based on current settings
155- storage . get < Settings > ( ' settings' ) . then ( ( settings ) => {
155+ storage . get < Settings > ( " settings" ) . then ( ( settings ) => {
156156 if ( settings ?. autoRedirect ) {
157157 startChecking ( ) ;
158158 }
159159} ) ;
160160
161161// Notification Card
162162export const getStyle : PlasmoGetStyle = ( ) => {
163- const style = document . createElement ( ' style' ) ;
164- style . textContent = styleText . replaceAll ( ' :root' , ' :host(plasmo-csui)' ) ;
163+ const style = document . createElement ( " style" ) ;
164+ style . textContent = styleText . replaceAll ( " :root" , " :host(plasmo-csui)" ) ;
165165 return style ;
166166} ;
167167
@@ -186,29 +186,29 @@ export default function Root() {
186186 chrome . runtime . onMessage . addListener ( async ( message ) => {
187187 const parsed = serverToClient . safeParse ( message ) ;
188188 if ( ! parsed . success ) {
189- logger . warn ( ' Invalid message' , parsed . error ) ;
189+ logger . warn ( " Invalid message" , parsed . error ) ;
190190 return ;
191191 }
192- if ( parsed . data . type === ' streamer-live' ) {
192+ if ( parsed . data . type === " streamer-live" ) {
193193 // Check settings before showing notification
194- const settings = await storage . get < Settings > ( ' settings' ) ;
194+ const settings = await storage . get < Settings > ( " settings" ) ;
195195 const favorites =
196- ( await storage . get < Streamer [ 'id' ] [ ] > ( ' favorites' ) ) || [ ] ;
196+ ( await storage . get < Streamer [ "id" ] [ ] > ( " favorites" ) ) || [ ] ;
197197 const blockedStreamers =
198- ( await storage . get < Streamer [ 'id' ] [ ] > ( ' blocked' ) ) || [ ] ;
198+ ( await storage . get < Streamer [ "id" ] [ ] > ( " blocked" ) ) || [ ] ;
199199
200200 // Skip if notifications are disabled
201201 if ( settings ?. notifyWhenStreamerIsLive === false ) {
202202 logger . info (
203- ' Notifications disabled, skipping content script notification'
203+ " Notifications disabled, skipping content script notification"
204204 ) ;
205205 return ;
206206 }
207207
208208 // Skip if streamer is blocked
209209 if ( blockedStreamers . includes ( parsed . data . data . id ) ) {
210210 logger . info (
211- ' Streamer is blocked, skipping content script notification'
211+ " Streamer is blocked, skipping content script notification"
212212 ) ;
213213 return ;
214214 }
@@ -219,7 +219,7 @@ export default function Root() {
219219 ! favorites . includes ( parsed . data . data . id )
220220 ) {
221221 logger . info (
222- ' Only favorite notifications enabled and streamer is not a favorite, skipping content script notification'
222+ " Only favorite notifications enabled and streamer is not a favorite, skipping content script notification"
223223 ) ;
224224 return ;
225225 }
0 commit comments