Skip to content

Commit

Permalink
Attempt to unbrick Discord on macOS (#441)
Browse files Browse the repository at this point in the history
  • Loading branch information
GriefMoDz committed Jan 10, 2021
1 parent 3091595 commit fada35c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/Powercord/plugins/pc-codeblocks/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ module.exports = class Codeblocks extends Plugin {
}

renderCodeblock (lang, lines) {
if (typeof hljs.getLanguage !== 'undefined') {
if (hljs && typeof hljs.getLanguage === 'function') {
lang = hljs.getLanguage(lang);
}

Expand Down
16 changes: 13 additions & 3 deletions src/browserWindow.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,20 @@ class PatchedBrowserWindow extends BrowserWindow {
originalPreload = opts.webPreferences.preload;
// opts.webPreferences.preload = join(__dirname, './preload.js');
} else if (opts.webPreferences && opts.webPreferences.preload) {
// Discord Client
originalPreload = opts.webPreferences.preload;
opts.webPreferences.preload = join(__dirname, './preload.js');
opts.webPreferences.contextIsolation = false;
if (originalPreload.endsWith('splashScreenPreload.js')) {
/**
* Splash Screen on macOS (Host 0.0.262+) - I expect this to change on other platforms too!
* @todo: Figure out a way to theme the splash screen again, as modifying the preload script
* prevents Discord from launching (i.e. bricks current install, unless unplugged)
*/

// opts.webPreferences.preload = join(__dirname, './preloadSplash.js');
} else {
// Discord Client
opts.webPreferences.preload = join(__dirname, './preload.js');
opts.webPreferences.contextIsolation = false;
}

if (transparency) {
opts.transparent = true;
Expand Down

0 comments on commit fada35c

Please sign in to comment.