From 8cafa686ab45cb1c76ce8ceb0b99252bde5d51bd Mon Sep 17 00:00:00 2001 From: Punikekk Date: Fri, 3 Nov 2023 19:54:21 +0100 Subject: [PATCH] v1.2.5 --- package.json | 3 ++- src/main.js | 67 ++++++++++++++++++++++++++++++++++++---------------- 2 files changed, 48 insertions(+), 22 deletions(-) diff --git a/package.json b/package.json index 2acdc03..65f5579 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "dark_backpage", - "version": "1.2.4", + "version": "1.2.5", "description": "DarkBot backpage", "main": "src/main.js", "scripts": { @@ -45,5 +45,6 @@ } }, "dependencies": { + "electron-context-menu": "^3.6.1" } } diff --git a/src/main.js b/src/main.js index bf313f5..3d23bcf 100644 --- a/src/main.js +++ b/src/main.js @@ -1,7 +1,9 @@ -const {app, BrowserWindow, session} = require('electron') -const path = require('path') +const {app, BrowserWindow} = require("electron") +const path = require("path") +const contextMenu = require("electron-context-menu"); -app.commandLine.appendSwitch('ppapi-flash-path', getFlashPath()) +process.env["ELECTRON_DISABLE_SECURITY_WARNINGS"] = "true"; +app.commandLine.appendSwitch("ppapi-flash-path", getFlashPath()) let mainWindow @@ -18,7 +20,6 @@ function createWindow() { icon: icon, show: false, darkTheme: true, - autoHideMenuBar: true, title: "Dark Backpage", webPreferences: { allowRunningInsecureContent: false, @@ -27,12 +28,36 @@ function createWindow() { // nodeIntegration: true, // contextIsolation: false, // enableRemoteModule: true, - preload: path.join(__dirname, 'preload.js') + preload: path.join(__dirname, "preload.js") } }) - mainWindow.webContents.userAgent = 'BigpointClient/1.6.9' - mainWindow.webContents.on('new-window', (event, url) => { + contextMenu({ + menu: (actions, props, browserWindow, dictionarySuggestions) => [ + { + label: "Forward", + click: () => mainWindow.webContents.goForward(), + visible: mainWindow.webContents.canGoForward() + }, + { + label: "Backward", + click: () => mainWindow.webContents.goBack(), + visible: mainWindow.webContents.canGoBack() + }, + actions.separator(), + { + role: "reload" + }, + { + role: "toggleDevTools" + }, + actions.inspect(), + actions.services(), + ] + }) + + mainWindow.webContents.userAgent = "BigpointClient/1.6.9" + mainWindow.webContents.on("new-window", (event, url) => { event.preventDefault() mainWindow.loadURL(url) }) @@ -43,7 +68,7 @@ function createWindow() { callback({cancel: cancel}) }) - mainWindow.on('page-title-updated', (evt) => { + mainWindow.on("page-title-updated", (evt) => { evt.preventDefault(); }); @@ -51,36 +76,36 @@ function createWindow() { .then(r => { const {url, sid} = parseArgv(); if (url && sid) { - mainWindow.webContents.session.cookies.set({url: url, name: 'dosid', value: sid}) - .then(() => mainWindow.loadURL(url + '/indexInternal.es?action=internalStart')) + mainWindow.webContents.session.cookies.set({url: url, name: "dosid", value: sid}) + .then(() => mainWindow.loadURL(url + "/indexInternal.es?action=internalStart")) } else { - mainWindow.loadURL('https://darkorbit.com') - //mainWindow.loadFile(path.join(__dirname, 'index.html')) + mainWindow.loadURL("https://darkorbit.com") + //mainWindow.loadFile(path.join(__dirname, "index.html")) } mainWindow.show(); }); } -process.env['ELECTRON_DISABLE_SECURITY_WARNINGS'] = 'true'; + app.whenReady().then(() => { createWindow() - app.on('activate', function () { + app.on("activate", function () { if (BrowserWindow.getAllWindows().length === 0) createWindow() }) }) -app.on('window-all-closed', function () { - if (process.platform !== 'darwin') app.quit() +app.on("window-all-closed", function () { + if (process.platform !== "darwin") app.quit() }) function parseArgv() { let url, sid for (let i = 0; i < process.argv.length && !(url && sid); i++) { switch (process.argv[i]) { - case '--url': + case "--url": url = process.argv[++i] break - case '--sid': + case "--sid": sid = process.argv[++i] } } @@ -90,12 +115,12 @@ function parseArgv() { function getFlashPath() { switch (process.platform) { case "darwin": - return path.join(process.resourcesPath, 'res', 'flash.plugin') + return path.join(process.resourcesPath, "res", "flash.plugin") case "linux": app.commandLine.appendSwitch("--no-sandbox") - return path.join(process.resourcesPath, 'res', 'libpepflashplayer.so') + return path.join(process.resourcesPath, "res", "libpepflashplayer.so") case "win32": - return path.join(process.resourcesPath, 'res', 'pepflashplayer.dll') + return path.join(process.resourcesPath, "res", "pepflashplayer.dll") } return "" } \ No newline at end of file