GitHub Desktop Theme Dark Fusion
This theme will override your current selected theme.
At the moment this theme has been tested only on macOS 10.14
let html_file_path;
if (fs.existsSync(path.join(res, ‘app/index.html’))) {
html_file_path = path.join(res, ‘app/index.html’);
} else if (fs.existsSync(path.join(res, ‘app/dist/index.html’))) {
html_file_path = path.join(res, ‘app/dist/index.html’);
} else {
throw new Error(Couldn't find index.html
);
}
let html = fs.readFileSync(html_file_path, “utf8”);
const link_to_inject = ‘ fusion@v0.5-alpha/desktop--dark-fusion.css" rel="stylesheet">‘;
html = html
.replace(/]+(cdn|custom-theme)[^>]+>/, ‘’) // remove existing custom stylesheet if there is one
.replace(‘‘, \n${link_to_inject}</head>
); // add stylesheet
try {
fs.writeFileSync(html_file_path, html, ‘utf8’);
} catch(error) {
if (html_file_path.startsWith(‘/tmp’)) {
console.error(The theme cannot be applied to the AppImage since 'index.html' is saved in a temporary directory.
)
} else if (error.code == ‘EACCES’) {
console.error(You need to have write access to '${html_file_path}' for the theme to be applied.
)
}
throw error;
}
// clear the cache so the stylesheet can update (could alternatively cache-bust with a URL parameter)
const {remote} = require(‘electron’);
const win = remote.getCurrentWindow();
win.webContents.session.clearCache(() => {
if (confirm(‘Ready to refresh? :)’)) {
location.reload();
}
});
```
GitHub Desktop will refresh and the theme should be applied.
You’ll need to reapply the stylesheet when GitHub Desktop updates.