#Help with insertCSS

28 messages · Page 1 of 1 (latest)

sand temple
#

css variable is undefined

heady acorn
#

i tried to print the css before inserting it, and it is actually valid css with no errors

sand temple
#

With current code I don't think so

heady acorn
sand temple
#

Show output from terminal

heady acorn
sand temple
#

Have you remove console.log from readFile?

heady acorn
#

no

sand temple
#

Remove it

heady acorn
#

okay

#

ohh now its printing "undefined"

#

so yea i think i messed up somewhere

#

strange

#
fs.readFile('./themes/dark.css', 'utf8', (err, data) => {
      if (err) {
        //console.error(err);
        alert(err)
        return;
      }
      console.log(data)
      win.webContents.insertCSS(data, 'utf-8');
    });```
Okay so i did that, now the inserted css is the css i want, but now, simply no change, just like i didnt inject the css
sand temple
#

Are you sure that utf-8 thing is valid?

#

In insertCSS

heady acorn
#

even if i remove that it still doesnt affect anything

sand temple
#

Do you have inserted css in dom?

heady acorn
#

win.once('DOMContentLoaded', () => {
win.webContents.insertCSS(data);
})

#

like this ?

#

yea tried that too

#

didnt work

sand temple
#

In devtools

heady acorn
#

lm try

#

yea it works from devtools

#

its correctly shown

sand temple
#

I mean if your css exists

#

After inserting it