mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-10 10:11:46 +00:00
fix injectCSS did-finish-load listener overload
This commit is contained in:
@ -42,15 +42,22 @@ module.exports.fileExists = (path, callbackIfExists) => {
|
||||
});
|
||||
};
|
||||
|
||||
const cssToInject = new Map();
|
||||
module.exports.injectCSS = (webContents, filepath, cb = undefined) => {
|
||||
webContents.on("did-finish-load", async () => {
|
||||
await webContents.insertCSS(fs.readFileSync(filepath, "utf8"));
|
||||
if (cb) {
|
||||
cb();
|
||||
}
|
||||
});
|
||||
if (!cssToInject.size) setupCssInjection(webContents);
|
||||
|
||||
cssToInject.set(filepath, cb);
|
||||
};
|
||||
|
||||
const setupCssInjection = (webContents) => {
|
||||
webContents.on("did-finish-load", () => {
|
||||
cssToInject.forEach(async (cb, filepath) => {
|
||||
await webContents.insertCSS(fs.readFileSync(filepath, "utf8"));
|
||||
cb?.();
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
module.exports.getAllPlugins = () => {
|
||||
const isDirectory = (source) => fs.lstatSync(source).isDirectory();
|
||||
return fs
|
||||
|
||||
Reference in New Issue
Block a user