Skip to content
This repository has been archived by the owner on Jun 27, 2021. It is now read-only.

Commit

Permalink
Merge pull request #156 from MasicoreLord/beta-patch
Browse files Browse the repository at this point in the history
Fixed devtools warning
  • Loading branch information
joe27g committed Feb 10, 2021
2 parents 8acb2a0 + 9c30275 commit 8c0348e
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 11 deletions.
7 changes: 4 additions & 3 deletions bd_shit.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ module.exports = class BDManager {
this.observer.observe(document, {childList: true, subtree: true});

//this.currentWindow.webContents.on('did-navigate-in-page', BDManager.onSwitch);
electron.ipcRenderer.invoke('bd-navigate-page-listener', BDManager.onSwitch);

try { electron.ipcRenderer.invoke('bd-navigate-page-listener', BDManager.onSwitch); }
catch(err) { throw new Error(`Could not add navigate page listener. ${err}\n${err.stack}`); };

fs.readFile(path.join(process.env.injDir, 'bd.css'), (err, text) => {
if (err) return console.error(err);
Expand All @@ -39,7 +39,8 @@ module.exports = class BDManager {
EDApi.clearCSS('BDManager');
this.observer.disconnect();
//this.currentWindow.webContents.removeEventListener('did-navigate-in-page', BDManager.onSwitch);
electron.ipcRenderer.invoke('remove-bd-navigate-page-listener', BDManager.onSwitch);
try { electron.ipcRenderer.invoke('remove-bd-navigate-page-listener', BDManager.onSwitch); }
catch(err) { throw new Error(`Could not remove navigate page listener. ${err}\n${err.stack}`); };
this.jqueryElement.remove();
Module._extensions['.js'] = originalRequire;
}
Expand Down
4 changes: 4 additions & 0 deletions dom_shit.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,10 @@ process.once('loaded', async () => {
EDApi.monkeyPatch(ht, 'showToken', window.fixedShowToken);
if (!ED.localStorage.getItem('token') && ht.getToken())
window.fixedShowToken(); // prevent you from being logged out for no reason

// change the console warning to be more fun
electron.ipcRenderer.invoke('custom-devtools-warning');

// expose stuff for devtools
Object.assign(electron.webFrame.top.context.window, {ED, EDApi, BdApi});
});
Expand Down
8 changes: 0 additions & 8 deletions injection.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,6 @@ class BrowserWindow extends electron.BrowserWindow {
originalOptions.webPreferences.preload = path.join(process.env.injDir, 'dom_shit.js');
originalOptions.webPreferences.transparency = true;

// change the console warning to be more fun
win.webContents.on('devtools-opened', (event) => {
console.log('%cHold Up!', 'color: #FF5200; -webkit-text-stroke: 2px black; font-size: 72px; font-weight: bold;');
console.log('%cIf you\'re reading this, you\'re probably smarter than most Discord developers.', 'font-size: 16px;');
console.log('%cPasting anything in here could actually improve the Discord client.', 'font-size: 18px; font-weight: bold; color: red;');
console.log('%cUnless you understand exactly what you\'re doing, keep this window open to browse our bad code.', 'font-size: 16px;');
console.log('%cIf you don\'t understand exactly what you\'re doing, you should come work with us: https://discordapp.com/jobs', 'font-size: 16px;');
});
win = new electron.BrowserWindow(originalOptions);
win.webContents.__preload = originalPreloadScript;
return win;
Expand Down
14 changes: 14 additions & 0 deletions main_process_shit.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,20 @@ ipcMain.on('main-process-utils', (event, arg) => {
}`
});

ipcMain.handle('custom-devtools-warning', (event, arg) => {
let wc = event.sender.getOwnerBrowserWindow().webContents;
wc.removeAllListeners('devtools-opened');
wc.on('devtools-opened', () => {
wc.executeJavaScript(`
console.log('%cHold Up!', 'color: #FF5200; -webkit-text-stroke: 2px black; font-size: 72px; font-weight: bold;');
console.log("%cIf you're reading this, you're probably smarter than most Discord developers.", 'font-size: 16px;');
console.log('%cPasting anything in here could actually improve the Discord client.', 'font-size: 18px; font-weight: bold; color: red;');
console.log("%cUnless you understand exactly what you're doing, keep this window open to browse our bad code.", 'font-size: 16px;');
console.log("%cIf you don't understand exactly what you\'re doing, you should come work with us: https://discordapp.com/jobs", 'font-size: 16px;');
`)
});
});

ipcMain.handle('bd-navigate-page-listener', (event, arg) => {
event.sender.getOwnerBrowserWindow().webContents.on('did-navigate-in-page', arg);
})
Expand Down

0 comments on commit 8c0348e

Please sign in to comment.