From fa1013102e9dbfd62ab132f67850fa860b412410 Mon Sep 17 00:00:00 2001 From: ToxicKwas1221 Date: Thu, 13 Aug 2020 20:25:38 +0200 Subject: [PATCH 1/8] made it work with test.html. makes discord corrupted --- electron/index.js | 14 +++++++------- electron/package.json | 1 + electron/preload.js | 3 +++ electron/test.html | 13 +++++++++++++ 4 files changed, 24 insertions(+), 7 deletions(-) create mode 100644 electron/preload.js create mode 100644 electron/test.html diff --git a/electron/index.js b/electron/index.js index b74af55..409ac55 100644 --- a/electron/index.js +++ b/electron/index.js @@ -10,26 +10,26 @@ async function createWindow() { width: 1920, height: 1080, icon: __dirname + "/buildResources/icon.png", + frame: false, webPreferences: { + preload: 'preload.js', webSecurity: true, - nodeIntegration: false, - enableRemoteModule: false, - contextIsolation: true, + nodeIntegration: true, + enableRemoteModule: true, + contextIsolation: false, }, }); - // win.webContents.openDevTools(); win.webContents.on("did-navigate", () => { win.webContents.executeJavaScript(`document.write(atob("${btoa(html)}"))`); + }); + if (systemPreferences && systemPreferences.askForMediaAccess) systemPreferences.askForMediaAccess("microphone"); win.webContents.on("new-window", function (e, url) { e.preventDefault(); require("electron").shell.openExternal(url); }); win.loadURL("https://blank.org"); - // win.loadURL("data:text/html;charset=UTF-8," + encodeURIComponent(html), { - // baseURLForDataURL: `file://${__dirname}/app`, - // }); const filter = { urls: [""], diff --git a/electron/package.json b/electron/package.json index 33c9174..172813a 100644 --- a/electron/package.json +++ b/electron/package.json @@ -57,6 +57,7 @@ }, "dependencies": { "btoa": "^1.2.1", + "custom-electron-titlebar": "^3.2.3", "node-fetch": "^2.6.0" } } diff --git a/electron/preload.js b/electron/preload.js new file mode 100644 index 0000000..3b6c6a4 --- /dev/null +++ b/electron/preload.js @@ -0,0 +1,3 @@ +const customTitlebar = require('custom-electron-titlebar'); +new customTitlebar.Titlebar({backgroundColor: customTitlebar.Color.fromHex('#2f3241')}); + diff --git a/electron/test.html b/electron/test.html new file mode 100644 index 0000000..96ddad0 --- /dev/null +++ b/electron/test.html @@ -0,0 +1,13 @@ + + + + test + + +

kek

+ + + \ No newline at end of file From 09fe68b556361baaa95266f4633a83896b727521 Mon Sep 17 00:00:00 2001 From: ToxicKwas1221 Date: Fri, 14 Aug 2020 02:19:07 +0200 Subject: [PATCH 2/8] works with index.html but parts of code are missing --- electron/{test.html => index.html} | 3 +-- electron/index.js | 6 ++++-- electron/preload.js | 3 --- 3 files changed, 5 insertions(+), 7 deletions(-) rename electron/{test.html => index.html} (87%) delete mode 100644 electron/preload.js diff --git a/electron/test.html b/electron/index.html similarity index 87% rename from electron/test.html rename to electron/index.html index 96ddad0..f9eec2e 100644 --- a/electron/test.html +++ b/electron/index.html @@ -1,10 +1,9 @@ - test + discord-bot-client -

kek

+ \ No newline at end of file diff --git a/electron/index.js b/electron/index.js index d80ee31..5adc30e 100644 --- a/electron/index.js +++ b/electron/index.js @@ -11,6 +11,7 @@ async function createWindow() { height: 1080, icon: __dirname + "/buildResources/icon.png", frame: false, + titleBarStyle: "hidden", webPreferences: { webSecurity: true, nodeIntegration: true, From 988d3be4bc295db321693866241de3ec2b8c3ffa Mon Sep 17 00:00:00 2001 From: ToxicKwas1221 Date: Mon, 17 Aug 2020 23:53:10 +0200 Subject: [PATCH 5/8] fixed the preload script. login page is default --- electron/index.html | 6 +----- electron/index.js | 6 ++++-- electron/preload.js | 13 +++++++++++++ 3 files changed, 18 insertions(+), 7 deletions(-) create mode 100644 electron/preload.js diff --git a/electron/index.html b/electron/index.html index 87ba0b5..ae66113 100644 --- a/electron/index.html +++ b/electron/index.html @@ -5,11 +5,7 @@ - - - \ No newline at end of file diff --git a/electron/index.js b/electron/index.js index 41a971f..4690e0e 100644 --- a/electron/index.js +++ b/electron/index.js @@ -10,7 +10,7 @@ async function createWindow() { let win = new BrowserWindow({ width: 1920, height: 1080, - icon: __dirname + "/buildResources/icon.png", + icon: path.join(__dirname, 'buildResources', 'icon.png'), frame: false, titleBarStyle: "hidden", webPreferences: { @@ -22,17 +22,8 @@ async function createWindow() { }, }); win.webContents.on("did-navigate", () => { - win.webContents.executeJavaScript(`document.querySelector(".container-after-titlebar").innerHTML = atob("${btoa(html)}")`); - win.webContents.executeJavaScript(` - const num = document.scripts.length; - for(var i = 0; i < num; i++){ - const target = document.querySelector(".container-after-titlebar"); - var newScript = document.createElement("script"); - var inlineScript = document.createTextNode(document.scripts.item(i).text); - newScript.appendChild(inlineScript); - target.appendChild(newScript); - } - `); + win.webContents.executeJavaScript(`document.write(atob("${btoa(html)}"))`); + win.webContents.executeJavaScript(`window.electron.buildTitleBar()`); }); @@ -42,7 +33,6 @@ async function createWindow() { require("electron").shell.openExternal(url); }); win.loadURL("https://blank.org"); - win.loadFile('index.html'); const filter = { urls: [""], diff --git a/electron/preload.js b/electron/preload.js index 41bca90..475b92e 100644 --- a/electron/preload.js +++ b/electron/preload.js @@ -6,6 +6,15 @@ function TitleBar(){ backgroundColor: customTitlebar.Color.fromHex('#202225'), itemBackgroundColor: customTitlebar.Color.fromHex('#282B2E'), }); + // add styles + document.querySelector('.titlebar').style.height = '22px'; + document.querySelector('.window-controls-container').style.height = '100%'; + document.querySelector('.menubar').style.visibility = 'hidden'; + var buttons = document.querySelectorAll('.window-icon-bg'); + for (var i = 0; i < buttons.length; i++) { + buttons[i].style.width = "28px"; + } + document.querySelector('.window-title').style.fontSize = '0px'; } contextBridge.exposeInMainWorld('electron', { From f46b8a68a3490420dfe9925b765803fbbcbb16d9 Mon Sep 17 00:00:00 2001 From: ToxicKwas1221 Date: Sun, 30 Aug 2020 19:02:42 +0200 Subject: [PATCH 7/8] svg logo added. gap fixed --- electron/preload.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/electron/preload.js b/electron/preload.js index 475b92e..0222b87 100644 --- a/electron/preload.js +++ b/electron/preload.js @@ -3,11 +3,13 @@ const { contextBridge } = require('electron'); function TitleBar(){ new customTitlebar.Titlebar({ - backgroundColor: customTitlebar.Color.fromHex('#202225'), - itemBackgroundColor: customTitlebar.Color.fromHex('#282B2E'), + backgroundColor: customTitlebar.Color.fromHex('#202225'), + itemBackgroundColor: customTitlebar.Color.fromHex('#282B2E'), + icon: 'discord.com/assets/93608abbd20d90c13004925014a9fd01.svg' }); // add styles document.querySelector('.titlebar').style.height = '22px'; + document.querySelector('.container-after-titlebar').style.marginTop = '-8px'; // removes the gap between the titlebar and the main content document.querySelector('.window-controls-container').style.height = '100%'; document.querySelector('.menubar').style.visibility = 'hidden'; var buttons = document.querySelectorAll('.window-icon-bg'); @@ -15,6 +17,15 @@ function TitleBar(){ buttons[i].style.width = "28px"; } document.querySelector('.window-title').style.fontSize = '0px'; + + //svg logo + document.querySelector('.window-appicon').innerHTML += `
`; } contextBridge.exposeInMainWorld('electron', { From 6452404ed8898a56d87c4b2ab0aa0d60a5eb3b4e Mon Sep 17 00:00:00 2001 From: ToxicKwas1221 Date: Thu, 17 Sep 2020 00:34:05 +0200 Subject: [PATCH 8/8] view button added --- electron/preload.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/electron/preload.js b/electron/preload.js index 0222b87..dc344a3 100644 --- a/electron/preload.js +++ b/electron/preload.js @@ -11,7 +11,17 @@ function TitleBar(){ document.querySelector('.titlebar').style.height = '22px'; document.querySelector('.container-after-titlebar').style.marginTop = '-8px'; // removes the gap between the titlebar and the main content document.querySelector('.window-controls-container').style.height = '100%'; - document.querySelector('.menubar').style.visibility = 'hidden'; + + // make view visible + var buttons = document.querySelectorAll('.menubar-menu-button'); + for (button of buttons){ + if (button.getAttribute('aria-label') != 'View'){ + button.style.visibility = 'hidden'; + } else { + button.style.height = '26px'; + } + } + var buttons = document.querySelectorAll('.window-icon-bg'); for (var i = 0; i < buttons.length; i++) { buttons[i].style.width = "28px";