Skip to content

Commit

Permalink
v1.0.4
Browse files Browse the repository at this point in the history
-Added launch parameters
-Development mode
-Launch with custom dosid
  • Loading branch information
kaiserdj committed Jan 15, 2021
1 parent f98e018 commit af106ca
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 38 deletions.
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"windows": {
"runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron.cmd"
},
"args" : ["."],
"args" : [".", "--d"],
"outputCapture": "std"
}
]
Expand Down
45 changes: 42 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,26 @@
const { app, BrowserWindow } = require('electron');
const yargs = require('yargs/yargs')
const { hideBin } = require('yargs/helpers')
const path = require('path');
const update = require("./update");
const userAgent = require("./useragent");

let argv = yargs(hideBin(process.argv))
.usage('Usage: $0 [options]')
.option('dosid', {
type: "string",
description: "Run client with custom dosid",
default: null
})
.option('dev', {
alias: 'd',
type: 'boolean',
description: 'Run in development mode',
default: false
})
.epilog('for more information visit https://github.com/kaiserdj/Darkorbit-client')
.argv;

async function createWindow() {
update.checkForUpdates()
let Useragent = await userAgent.getVersion()
Expand All @@ -15,23 +33,44 @@ async function createWindow() {
'webPreferences': {
'contextIsolation': true,
'nodeIntegration': true,
'plugins': true
'plugins': true,
'devTools': argv.dev
},
});

mainWindow.loadURL(`https://www.darkorbit.com/`, { userAgent: Useragent })
if (argv.dev) {
mainWindow.webContents.openDevTools()
}

if (argv.dosid) {
let sid = argv.dosid.match(/[?&](dosid|sid)=([^&]+)/);
let baseUrl = new URL(argv.dosid).origin;

if (sid !== null && baseUrl !== null) {
const cookie = { url: baseUrl, name: 'dosid', value: sid[2] };
mainWindow.webContents.session.cookies.set(cookie);
mainWindow.loadURL(`${baseUrl}/indexInternal.es?action=internalStart`, { userAgent: Useragent });
}
} else {
mainWindow.loadURL(`https://www.darkorbit.com/`, { userAgent: Useragent });
}

mainWindow.webContents.on('new-window', async function(e, url) {
e.preventDefault()
const external = new BrowserWindow({
'webPreferences': {
'contextIsolation': true,
'nodeIntegration': true,
'plugins': true
'plugins': true,
'devTools': argv.dev
}
});

external.loadURL(url, { userAgent: Useragent });

if (argv.dev) {
external.webContents.openDevTools()
}
});
}

Expand Down
44 changes: 12 additions & 32 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "darkorbit-client",
"version": "1.0.3",
"version": "1.0.4",
"description": "Open source darkorbit client",
"main": "index.js",
"repository": {
Expand All @@ -24,7 +24,8 @@
"dependencies": {
"electron-progressbar": "^2.0.0",
"electron-updater": "^4.3.5",
"xml2js": "^0.4.23"
"xml2js": "^0.4.23",
"yargs": "^16.2.0"
},
"build": {
"appId": "com.DarkOrbitClient.Kaiserdj",
Expand Down

0 comments on commit af106ca

Please sign in to comment.