-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
162 lines (141 loc) Β· 5.38 KB
/
Copy pathmain.js
File metadata and controls
162 lines (141 loc) Β· 5.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
const { app, BrowserWindow, ipcMain, dialog, shell } = require('electron');
const path = require('path');
const fs = require('fs');
const { execSync } = require('child_process');
// Ensure single AppData directory: 'Orbit Hide'
try {
app.setPath('userData', path.join(app.getPath('appData'), 'Orbit Hide'));
} catch (_) {}
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
// PURE STEALTH MODE FOR RIGHT-CLICK CONTEXT MENU
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
const args = process.argv;
const hideIdx = args.indexOf('--hide');
const isSilentHide = (hideIdx !== -1 && args[hideIdx + 1]);
if (isSilentHide) {
// Execute completely in the background β ZERO windows, ZERO notifications!
const targetPath = args[hideIdx + 1];
try {
const APP_DIR = path.join(process.env.APPDATA || path.join(process.env.HOME, 'AppData', 'Roaming'), 'Orbit Hide');
const DB_FILE = path.join(APP_DIR, 'vault_db.json');
if (!fs.existsSync(APP_DIR)) fs.mkdirSync(APP_DIR, { recursive: true });
const clean = path.normalize(targetPath.trim());
let db = { auth: { isSetup: false }, items: [], logs: [] };
if (fs.existsSync(DB_FILE)) {
try { db = JSON.parse(fs.readFileSync(DB_FILE, 'utf8')); } catch (_) {}
}
if (!Array.isArray(db.items)) db.items = [];
if (!Array.isArray(db.logs)) db.logs = [];
let item = db.items.find(i => i.itemPath.toLowerCase() === clean.toLowerCase());
if (!item) {
let isDir = false;
try { isDir = fs.existsSync(clean) && fs.statSync(clean).isDirectory(); } catch (_) {}
item = {
id: 'item_' + Date.now() + '_' + Math.random().toString(36).slice(2, 6),
name: path.basename(clean) || clean,
itemPath: clean,
isDirectory: isDir,
isHidden: false,
dateAdded: new Date().toISOString()
};
db.items.unshift(item);
}
try {
execSync(`attrib +h +s "${clean.replace(/["]/g, '').replace(/\\+$/, '')}"`, { windowsHide: true });
item.isHidden = true;
} catch (_) {}
db.logs.unshift({
id: 'log_' + Date.now(),
timestamp: new Date().toISOString(),
action: 'STEALTH_CONTEXT_HIDE',
targetPath: clean,
success: true,
details: 'Hidden via pure stealth context menu'
});
fs.writeFileSync(DB_FILE, JSON.stringify(db, null, 2), 'utf8');
} catch (e) {
console.error('Stealth hide error:', e);
}
// Exit immediately in background without opening any window
app.quit();
process.exit(0);
}
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
// NORMAL GUI APPLICATION MODE
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
try {
require('./server.js');
} catch (e) {
console.log('Internal server load notice:', e);
}
let mainWindow;
function createWindow() {
mainWindow = new BrowserWindow({
width: 1100,
height: 720,
minWidth: 850,
minHeight: 550,
title: 'Orbit Hide',
icon: path.join(__dirname, 'build', 'icon.png'),
backgroundColor: '#111111',
autoHideMenuBar: true,
webPreferences: {
nodeIntegration: true,
contextIsolation: false
}
});
// Open external links in default browser
mainWindow.webContents.setWindowOpenHandler(({ url }) => {
try { shell.openExternal(url); } catch (_) {}
return { action: 'deny' };
});
loadAppWithRetry(15);
mainWindow.on('closed', () => {
mainWindow = null;
});
}
function loadAppWithRetry(retries = 15) {
if (!mainWindow) return;
mainWindow.loadURL('http://localhost:3000').catch((err) => {
if (retries > 0) {
setTimeout(() => loadAppWithRetry(retries - 1), 250);
} else {
console.error('Express server initialization timeout:', err);
}
});
}
ipcMain.handle('select-file-item', async () => {
if (!mainWindow) return null;
const result = await dialog.showOpenDialog(mainWindow, {
title: 'Select Any File for Orbit Hide',
properties: ['openFile'],
buttonLabel: 'Select File'
});
if (!result.canceled && result.filePaths && result.filePaths.length > 0) {
return result.filePaths[0];
}
return null;
});
ipcMain.handle('select-folder-item', async () => {
if (!mainWindow) return null;
const result = await dialog.showOpenDialog(mainWindow, {
title: 'Select Any Folder for Orbit Hide',
properties: ['openDirectory'],
buttonLabel: 'Select Folder'
});
if (!result.canceled && result.filePaths && result.filePaths.length > 0) {
return result.filePaths[0];
}
return null;
});
app.whenReady().then(createWindow);
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit();
}
});
app.on('activate', () => {
if (BrowserWindow.getAllWindows().length === 0) {
createWindow();
}
});