Skip to content
This repository has been archived by the owner on Aug 10, 2024. It is now read-only.

Commit

Permalink
electron build
Browse files Browse the repository at this point in the history
  • Loading branch information
SamuelScheit committed Aug 5, 2020
1 parent b0cc311 commit 89fc11a
Show file tree
Hide file tree
Showing 14 changed files with 189 additions and 883 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ package-lock.json
test2.js
config.json
npm-debug.log
extension.pem
extension.pem
dist/
45 changes: 0 additions & 45 deletions cloudflare/worker.js

This file was deleted.

29 changes: 0 additions & 29 deletions electron.js

This file was deleted.

Binary file added electron/buildResources/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 27 additions & 0 deletions electron/dist/builder-effective-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
directories:
output: dist
buildResources: build
mac:
category: public.app-category.social-networking
target:
- dmg
- zip
icon: buildResources/icon.png
linux:
target:
- AppImage
- deb
- rpm
- freebsd
- pacman
- p5p
- apk
icon: buildResources/icon.png
win:
target:
- target: nsis
arch:
- x64
- ia32
icon: buildResources/icon.png
electronVersion: 9.1.2
76 changes: 76 additions & 0 deletions electron/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
const { app, BrowserWindow, systemPreferences } = require("electron");
const fetch = require("node-fetch");
const btoa = require("btoa");

async function createWindow() {
var html = await fetch("https://raw.githubusercontent.com/Flam3rboy/discord-bot-client/master/index.html");
html = await html.text();
// Create the browser window.
let win = new BrowserWindow({
width: 1920,
height: 1080,
icon: __dirname + "/buildResources/icon.png",
webPreferences: {
webSecurity: true,
nodeIntegration: false,
enableRemoteModule: false,
contextIsolation: true,
},
});
// win.webContents.openDevTools();
win.webContents.on("did-navigate", () => {
win.webContents.executeJavaScript(`document.write(atob("${btoa(html)}"))`);
});
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: ["<all_urls>"],
};
const { session } = win.webContents;

session.webRequest.onBeforeSendHeaders(filter, (details, callback) => {
details.requestHeaders["origin"] = "https://discord.com";
if (
[
"https://discord.com/api/v6/users/@me/library",
"https://discord.com/api/v6/users/@me/guilds/premium/subscriptions",
"https://discord.com/api/v6/science",
].includes(details.url) ||
details.url.includes("https://discord.com/api/v6/users/@me/billing/trials/") ||
details.url.includes("https://discord.com/api/v6/users/@me/applications/")
) {
return callback({ cancel: true });
}
delete details.requestHeaders["User-Agent"];

callback({ requestHeaders: details.requestHeaders });
});

session.webRequest.onHeadersReceived(filter, (details, callback) => {
details.responseHeaders["access-control-allow-origin"] = "*";

callback({ responseHeaders: details.responseHeaders });
});
}

app.whenReady().then(createWindow);

app.on("window-all-closed", () => {
if (process.platform !== "darwin") {
app.quit();
}
});

app.on("activate", () => {
if (BrowserWindow.getAllWindows().length === 0) {
createWindow();
}
});
63 changes: 63 additions & 0 deletions electron/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
{
"name": "discord-bot-client",
"version": "3.1.0",
"description": "Discord Bot Client - login into discord with a bot token",
"main": "index.js",
"scripts": {
"pack": "electron-builder --dir -mwl",
"dist": "electron-builder -mwl"
},
"keywords": [],
"author": {
"name": "Flam3rboy",
"email": "[email protected]"
},
"repository": {
"url": "https://github.com/Flam3rboy/discord-bot-client/"
},
"license": "ISC",
"productName": "Discord Bot Client",
"appId": "com.electron.discord-bot-client",
"devDependencies": {
"electron": "^9.1.2",
"electron-builder": "^22.8.0"
},
"build": {
"mac": {
"category": "public.app-category.social-networking",
"target": [
"dmg",
"zip"
],
"icon": "buildResources/icon.png"
},
"linux": {
"target": [
"AppImage",
"deb",
"rpm",
"freebsd",
"pacman",
"p5p",
"apk"
],
"icon": "buildResources/icon.png"
},
"win": {
"target": [
{
"target": "nsis",
"arch": [
"x64",
"ia32"
]
}
],
"icon": "buildResources/icon.png"
}
},
"dependencies": {
"btoa": "^1.2.1",
"node-fetch": "^2.6.0"
}
}
Binary file modified extension.zip
Binary file not shown.
11 changes: 4 additions & 7 deletions extension/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,10 @@
"background": {
"scripts": ["script.js"]
},
"permissions": [
"webRequest",
"webRequestBlocking",
"https://botclient.tk/",
"https://*.discord.com/",
"wss://gateway.discord.gg/"
],
"permissions": ["webRequest", "webRequestBlocking", "<all_urls>"],
"page_action": {
"default_popup": "popup.html"
},
"icons": {
"16": "images/16.png",
"32": "images/32.png",
Expand Down
12 changes: 12 additions & 0 deletions extension/popup.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html>
<head>
<title>Discord Bot Client</title>
</head>
<body>
<ul>
<li></li>
</ul>
<script src="popup.js"></script>
</body>
</html>
Empty file added extension/popup.js
Empty file.
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
{
"name": "discord-bot-client",
"version": "2.0.0",
"description": "",
"version": "3.1.0",
"description": "Discord Bot Client - login into discord with a bot token",
"main": "index.js",
"scripts": {
"build": "webpack --progress --colors --watch",
"start": "node index.js"
"start": "node index.js",
"electron": "electron electron/electron.js"
},
"keywords": [],
"author": "",
"author": "Flam3rboy",
"license": "ISC",
"dependencies": {
"express": "^4.17.1"
Expand All @@ -20,7 +21,6 @@
"@babel/register": "^7.0.0",
"babel-loader": "^8.0.6",
"circular-dependency-plugin": "^5.0.2",
"electron": "^9.0.4",
"gulp": "^4.0.0",
"gulp-babel-minify": "^0.5.1",
"gulp-csso": "^3.0.1",
Expand Down
Loading

0 comments on commit 89fc11a

Please sign in to comment.