mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-11 18:41:47 +00:00
Allow user to pass custom CSS file
This commit is contained in:
16
index.js
16
index.js
@ -84,6 +84,22 @@ function onClosed() {
|
||||
|
||||
function loadPlugins(win) {
|
||||
injectCSS(win.webContents, path.join(__dirname, "youtube-music.css"));
|
||||
// Load user CSS
|
||||
const cssFiles = config.get("options.cssFiles");
|
||||
if (Array.isArray(cssFiles)) {
|
||||
cssFiles.forEach((cssFile) => {
|
||||
fileExists(
|
||||
cssFile,
|
||||
() => {
|
||||
injectCSS(win.webContents, cssFile);
|
||||
},
|
||||
() => {
|
||||
console.warn(`CSS file "${cssFile}" does not exist, ignoring`);
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
win.webContents.once("did-finish-load", () => {
|
||||
if (is.dev()) {
|
||||
console.log("did finish load");
|
||||
|
||||
@ -32,9 +32,16 @@ module.exports.listenAction = (channel, callback) => {
|
||||
return ipcMain.on(channel, callback);
|
||||
};
|
||||
|
||||
module.exports.fileExists = (path, callbackIfExists) => {
|
||||
module.exports.fileExists = (
|
||||
path,
|
||||
callbackIfExists,
|
||||
callbackIfError = undefined
|
||||
) => {
|
||||
fs.access(path, fs.F_OK, (err) => {
|
||||
if (err) {
|
||||
if (callbackIfError) {
|
||||
callbackIfError();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user