Skip to content
This repository was archived by the owner on Aug 10, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions electron/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!DOCTYPE html>
<html>
<head>
<title>discord-bot-client</title>
</head>
<body>
<script type="text/javascript">
window.electron.buildTitleBar();
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';
</script>

</body>
</html>
25 changes: 19 additions & 6 deletions electron/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const { app, BrowserWindow, systemPreferences } = require("electron");
const fetch = require("node-fetch");
const btoa = require("btoa");
const path = require('path');

async function createWindow() {
var html = await fetch("https://raw.githubusercontent.com/Flam3rboy/discord-bot-client/master/index.html");
Expand All @@ -10,26 +11,38 @@ async function createWindow() {
width: 1920,
height: 1080,
icon: __dirname + "/buildResources/icon.png",
frame: false,
titleBarStyle: "hidden",
webPreferences: {
preload: path.join(__dirname, 'preload.js'),
webSecurity: true,
nodeIntegration: false,
enableRemoteModule: false,
enableRemoteModule: true,
contextIsolation: true,
},
});
// win.webContents.openDevTools();
win.webContents.on("did-navigate", () => {
win.webContents.executeJavaScript(`document.write(atob("${btoa(html)}"))`);
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);
}
`);

});

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`,
// });
win.loadFile('index.html');

const filter = {
urls: ["<all_urls>"],
Expand Down
1 change: 1 addition & 0 deletions electron/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
},
"dependencies": {
"btoa": "^1.2.1",
"custom-electron-titlebar": "^3.2.3",
"node-fetch": "^2.6.0"
}
}
13 changes: 13 additions & 0 deletions electron/preload.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const customTitlebar = require('custom-electron-titlebar');
const { contextBridge } = require('electron');

function TitleBar(){
new customTitlebar.Titlebar({
backgroundColor: customTitlebar.Color.fromHex('#202225'),
itemBackgroundColor: customTitlebar.Color.fromHex('#282B2E'),
});
}

contextBridge.exposeInMainWorld('electron', {
buildTitleBar: TitleBar,
});