I’m trying to create a simple web wrapper for a messaging website as practice, and I’ve created this simple code to load that website into Electron. Now I want to change this site’s CSS properties. Multiple sources, including the docs seem to imply that using .webContents.insertCSS is the easiest way to do this. But whenever I run my program, this doesn’t work.
Here is the code that I have been working with:
const {app, BrowserWindow, webContents} = require('electron');
const fs = require('fs');
const createWindow = () => {
let win = new BrowserWindow({
width: 800,
height: 600
})
win.loadURL('https://messenger.com/login');
win.webContents.insertCSS(`.rq0escxv.l9j0dhe7.du4w35lb.j83agx80.cbu4d94t.g5gj957u.d2edcug0.hpfvmrgz.kud993qy.buofh1pr {
margin-top: unset !important;
}
/* Scrollbar fixes. */
::-webkit-scrollbar {
width: 0px !important;
overflow-x: hidden;
}
:root, .__fb-light-mode, .__fb-dark-mode{
--messenger-card-background: #262626 !important;
--surface-background: #353535 !important;
--hosted-view-selected-state: #262626 !important;
}
.system-fonts--body{
font-family: 'Geist Regular' !important;
}
.x1247r65{
width: 0px !important;
visibility: hidden !important;
}
.x9f619.x1n2onr6.x1ja2u2z
.x78zum5.xdt5ytf.x2lah0s
.x193iq5w.xurb0ha.x1sxyh0
.xdj266r{
display: none !important;
}
.x1heor9g.x1qlqyl8.x1pd3egz.x1a2a7pz{
margin-left: 0px !important;
}
.xm81vs4,.xy80clv{
border-right-width: 0px !important;
border-left-width: 0px !important;
}
`);
}
app.whenReady().then(() => {
createWindow()
})
Thanks for the answer in advance!