@@ -29,6 +29,14 @@ const PERSIST_FILE = path.join(app.getPath('userData'), 'lastOpened.json')
2929
3030const DEFAULT_SAVE_INTERVAL = 30 * 1000
3131
32+ // See if we have any stylesheets with rules
33+ // If not manually inject styles to be like Agregore
34+ const HAS_SHEET = `
35+ [...document.styleSheets].filter((sheet) => {
36+ try {sheet.cssRules; return true} catch {return false}
37+ }).length
38+ `
39+
3240const WINDOW_METHODS = [
3341 'goBack' ,
3442 'goForward' ,
@@ -323,6 +331,15 @@ export class Window extends EventEmitter {
323331 this . send ( 'update-target-url' , url )
324332 } )
325333
334+ this . web . on ( 'dom-ready' , async ( ) => {
335+ const hasStyles = await this . web . executeJavaScript ( HAS_SHEET )
336+ console . log ( { hasStyles } )
337+ if ( ! hasStyles ) {
338+ const style = await getDefaultStylesheet ( this . web )
339+ await this . web . insertCSS ( style )
340+ }
341+ } )
342+
326343 this . web . once ( 'dom-ready' , ( ) => {
327344 showQueue . add ( async ( ) => {
328345 await this . window . show ( )
@@ -467,3 +484,16 @@ export class Window extends EventEmitter {
467484 return this . window . webContents . id
468485 }
469486}
487+
488+ async function getDefaultStylesheet ( webContents ) {
489+ const [ r1 , r2 ] = await Promise . all ( [
490+ webContents . session . fetch ( 'agregore://theme/vars.css' ) ,
491+ webContents . session . fetch ( 'agregore://theme/style.css' )
492+ ] )
493+
494+ const [ vars , style ] = await Promise . all ( [
495+ r1 . text ( ) ,
496+ r2 . text ( )
497+ ] )
498+ return vars + style
499+ }
0 commit comments