Skip to content
Closed
Show file tree
Hide file tree
Changes from all 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
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,15 @@ or just run `build.bat`. You get:
| **Fix and restart** | Appears when something breaks. Force-closes every Discord process, frees the debug port and starts over |
| **?** | Instructions, FAQ and warnings |

Close the window and farming stops. Discord keeps running.
When **Minimize to system tray** is enabled, the window's minimize and close buttons hide OrbSniper in the Windows tray and the worker keeps running. Choose **Quit** from the tray menu to stop the worker and exit. With tray mode disabled, closing the app exits normally.

## Quest manager and settings

Open **Quest queue** to see available quests, their game/task type, duration, current status and Orb reward. Uncheck quests you do not want OrbSniper to process, use the arrows to arrange the queue, enable **Only accept quests that pay Orbs**, or let the app prioritize higher Orb rewards. Manual queue order takes priority over automatic reward sorting. Queue changes apply after the current quest finishes; a reward that has already been claimed cannot be undone.

Open **Settings** to choose the light or dark appearance, launch OrbSniper when Windows starts, and minimize it to the system tray. Enable **Start farming automatically** as well to begin the worker at sign-in. For OrbSniper to launch Discord first with the debugging port, disable Discord's own entry under **Task Manager → Startup apps**. If Discord is already running without a debugging port, auto-start leaves it untouched and shows a warning rather than closing and reopening it. These preferences and the quest queue are saved locally on your PC.

While a quest is active, the elapsed timer updates every second and the app estimates time remaining from recent progress. The main screen also shows the Discord account name and Orb balance when the running Discord client exposes that information; the balance may be unavailable on some client builds.

## Languages

Expand Down
2 changes: 2 additions & 0 deletions README.ru.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ npm run dist

Закрыл окно — фарм остановился. Discord продолжит работать.

Чтобы запускать фарм автоматически при входе в Windows, включи **«Запускать при старте Windows»** и **«Начинать фарм автоматически»** в настройках. Чтобы OrbSniper первым открыл Discord с портом отладки, отключи собственный автозапуск Discord в **Диспетчере задач → Автозагрузка**. Если Discord уже запущен без порта отладки, автозапуск OrbSniper не будет закрывать и открывать его заново — появится предупреждение.

## Языки

Русский, English, 中文, Español, Português, Deutsch, Français, Polski, Türkçe, Українська.
Expand Down
228 changes: 213 additions & 15 deletions main.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/*!
* OrbSniper v1.6.0 - Discord Orb farmer (GUI)
* OrbSniper v1.7.0 - Discord Orb farmer (GUI)
* Copyright (c) 2026 synaps_ss - tg: @synaps_ss
* Licensed under MIT.
*/

const { app, BrowserWindow, ipcMain, clipboard, shell } = require("electron");
const { app, BrowserWindow, ipcMain, clipboard, shell, Tray, Menu, nativeImage } = require("electron");

const DONATE_ADDRESS = "TJXGAkovUoA2z9C7mWBiB9SGLVQu6oSsf";
const { execFileSync, spawn } = require("child_process");
Expand All @@ -15,7 +15,7 @@ const net = require("net");
const crypto = require("crypto");
const WebSocket = require("ws");

const VERSION = "1.6.0";
const VERSION = "1.7.0";

// 9222 is the conventional CDP port, which is exactly why it is so often taken
// by some other Electron app. We try it first and fall back to a free one.
Expand Down Expand Up @@ -43,14 +43,162 @@ const state = {
pending: new Map() // CDP message id -> handler
};

const DEFAULT_SETTINGS = Object.freeze({
launchAtLogin: false,
autoStartFarming: false,
minimizeToTray: false,
theme: "dark",
prioritizeOrbs: true,
orbOnly: false,
excludedQuestIds: [],
questOrder: []
});
let appSettings = { ...DEFAULT_SETTINGS };
let tray = null;
let isQuitting = false;

function cleanIdList(value) {
return Array.isArray(value)
? [...new Set(value.map(v => String(v)).filter(v => v && v.length <= 64))].slice(0, 300)
: [];
}
function normalizeSettings(value) {
const v = value && typeof value === "object" ? value : {};
return {
autoStartFarming: v.autoStartFarming === true,
launchAtLogin: v.launchAtLogin === true || v.autoStartFarming === true,
minimizeToTray: v.minimizeToTray === true,
theme: v.theme === "light" ? "light" : "dark",
prioritizeOrbs: v.prioritizeOrbs !== false,
orbOnly: v.orbOnly === true,
excludedQuestIds: cleanIdList(v.excludedQuestIds),
questOrder: cleanIdList(v.questOrder)
};
}
function settingsPath() {
try { return path.join(app.getPath("userData"), "settings.json"); }
catch (_) { return null; }
}
function readSettings() {
try {
const file = settingsPath();
if (file && fs.existsSync(file)) return normalizeSettings(JSON.parse(fs.readFileSync(file, "utf8")));
} catch (_) {}
return { ...DEFAULT_SETTINGS };
}
function writeSettings() {
try {
const file = settingsPath();
if (!file) return;
fs.mkdirSync(path.dirname(file), { recursive: true });
fs.writeFileSync(file, JSON.stringify(appSettings, null, 2), "utf8");
} catch (e) {
uiLog("[!] Could not save settings: " + ((e && e.message) || e));
}
}
function questPreferences() {
return {
prioritizeOrbs: appSettings.prioritizeOrbs,
orbOnly: appSettings.orbOnly,
excludedQuestIds: appSettings.excludedQuestIds.slice(),
questOrder: appSettings.questOrder.slice()
};
}
function syncEnginePreferences() {
if (!state.running || !state.ws || state.ws.readyState !== WebSocket.OPEN) return;
const value = JSON.stringify(questPreferences());
evalInPage(`window.__ORB_PREFERENCES__ = ${value}; if (window.__ORB__) window.__ORB__.preferences = window.__ORB_PREFERENCES__;`);
}
function applyStartupSetting() {
if (process.platform !== "win32") return;
try {
const args = app.isPackaged ? [] : [app.getAppPath()];
if (appSettings.autoStartFarming) args.push("--autostart");
if (appSettings.minimizeToTray) args.push("--hidden");
app.setLoginItemSettings({ openAtLogin: appSettings.launchAtLogin, path: process.execPath, args });
} catch (e) {
uiLog("[!] Could not update Windows startup setting: " + ((e && e.message) || e));
}
}
function ensureTray() {
if (tray) return true;
if (process.platform !== "win32") return false;
try {
const image = nativeImage.createFromPath(path.join(__dirname, "icon.ico"));
if (!image || image.isEmpty()) return false;
tray = new Tray(image.resize({ width: 16, height: 16 }));
tray.setToolTip("OrbSniper");
tray.setContextMenu(Menu.buildFromTemplate([
{ label: "Open OrbSniper", click: showMainWindow },
{ type: "separator" },
{ label: state.running ? "Quest worker: running" : "Quest worker: stopped", enabled: false },
{ type: "separator" },
{ label: "Quit", click: quitApplication }
]));
tray.on("click", showMainWindow);
tray.on("double-click", showMainWindow);
return true;
} catch (_) {
tray = null;
return false;
}
}
function syncTray() {
if (appSettings.minimizeToTray) ensureTray();
else if (tray) { try { tray.destroy(); } catch (_) {} tray = null; }
}
function updateTrayStatus() {
if (!tray) return;
try {
tray.setToolTip(state.running ? "OrbSniper — running" : "OrbSniper — stopped");
tray.setContextMenu(Menu.buildFromTemplate([
{ label: "Open OrbSniper", click: showMainWindow },
{ type: "separator" },
{ label: state.running ? "Quest worker: running" : "Quest worker: stopped", enabled: false },
{ type: "separator" },
{ label: "Quit", click: quitApplication }
]));
} catch (_) {}
}
function showMainWindow() {
if (!win || win.isDestroyed()) return;
win.show();
if (win.isMinimized()) win.restore();
win.focus();
}
function hideMainWindow() {
if (!win || win.isDestroyed()) return false;
if (appSettings.minimizeToTray && ensureTray()) { win.hide(); return true; }
win.minimize();
return false;
}
function quitApplication() {
if (isQuitting) return;
isQuitting = true;
const wasRunning = state.running;
if (wasRunning) stopFlow();
if (tray) { try { tray.destroy(); } catch (_) {} tray = null; }
// Let the stop flag reach Discord before Electron tears down its CDP socket.
if (wasRunning) setTimeout(() => app.quit(), 350);
else app.quit();
}
function saveSettings(patch) {
appSettings = normalizeSettings({ ...appSettings, ...(patch && typeof patch === "object" ? patch : {}) });
writeSettings();
applyStartupSetting();
syncTray();
syncEnginePreferences();
return { ...appSettings };
}

// ---------- UI helpers ----------
function send(channel, payload) {
if (win && !win.isDestroyed()) win.webContents.send(channel, payload);
}
function uiLog(msg) { send("sniper:log", msg); }
function say(key, level, ...args) { send("sniper:say", { key, level, args }); }
function phase(p) { send("sniper:phase", p); }
function setRunning(v) { state.running = v; send("sniper:running", v); }
function setRunning(v) { state.running = v; send("sniper:running", v); updateTrayStatus(); }

// Every failure path must go through here. Leaving state.running true was what
// wedged the UI: the Start button stayed disabled and runFlow() returned early
Expand Down Expand Up @@ -404,7 +552,9 @@ function injectEngine() {

let code;
try {
code = fs.readFileSync(path.join(__dirname, "quest.js"), "utf8").replace("__ORB_SESSION__", session);
const preferences = JSON.stringify(questPreferences());
code = `window.__ORB_PREFERENCES__ = ${preferences};\n` +
fs.readFileSync(path.join(__dirname, "quest.js"), "utf8").replace("__ORB_SESSION__", session);
} catch (e) {
state.injecting = false;
fail("l_injectfail", "err", String((e && e.message) || e));
Expand Down Expand Up @@ -455,7 +605,16 @@ function handleEngineEvent(e) {
send("sniper:tally", { total: e.total, done: e.done, left: e.left, manual: e.manual });
return;
case "progress":
send("sniper:progress", { quest: e.quest, task: e.task, done: e.done, need: e.need, elapsed: e.elapsed });
send("sniper:progress", { quest: e.quest, task: e.task, game: e.game, done: e.done, need: e.need, elapsed: e.elapsed });
return;
case "quests":
send("sniper:quests", e.quests || []);
return;
case "account":
send("sniper:account", e.account || null);
return;
case "balance":
send("sniper:balance", { value: e.value == null ? null : e.value });
return;
case "all_done":
send("sniper:done", { done: e.done, manual: e.manual });
Expand Down Expand Up @@ -631,7 +790,7 @@ async function preflight() {
}

// ---------- main flow ----------
async function runFlow() {
async function runFlow({ startup = false } = {}) {
if (state.running) return;
state.stopping = false;
setRunning(true);
Expand All @@ -655,6 +814,15 @@ async function runFlow() {
// Only restart Discord when it is actually running without the port. If it
// is closed we just start it, and nothing has to be killed.
if (discordPids().length > 0) {
if (startup) {
// On Windows login, never kill/relaunch a normal Discord instance:
// doing so causes the visible close/reopen cycle users asked to avoid.
// Disable Discord's own startup entry so OrbSniper can launch it with
// the debugging port after this app has initialized.
say("l_autostart_discord_running", "warn");
fail(null);
return;
}
phase("closing");
say("l_closing", "info");
const closed = await killDiscordAndWait();
Expand Down Expand Up @@ -743,6 +911,8 @@ ipcMain.handle("sniper:repair", async () => {

ipcMain.handle("sniper:stop", () => { stopFlow(); return true; });
ipcMain.handle("sniper:skip", () => { evalInPage("window.__ORB__ && (window.__ORB__.skip = true)"); return true; });
ipcMain.handle("app:getSettings", () => ({ ...appSettings }));
ipcMain.handle("app:saveSettings", (_e, patch) => saveSettings(patch));
ipcMain.handle("app:copy", (_e, text) => { clipboard.writeText(String(text || "")); return true; });
ipcMain.handle("app:version", () => VERSION);
ipcMain.handle("app:donateAddress", () => DONATE_ADDRESS);
Expand All @@ -752,8 +922,12 @@ ipcMain.handle("app:open", (_e, url) => {
shell.openExternal(u);
return true;
});
ipcMain.handle("win:minimize", () => { if (win) win.minimize(); });
ipcMain.handle("win:close", () => { if (win) win.close(); });
ipcMain.handle("win:minimize", () => hideMainWindow());
ipcMain.handle("win:close", () => {
if (appSettings.minimizeToTray && ensureTray()) { if (win) win.hide(); return true; }
quitApplication();
return true;
});

// ---------- window ----------
function createWindow() {
Expand All @@ -767,9 +941,9 @@ function createWindow() {
// Shown straight away instead of on ready-to-show: the window is up a
// good part of a second sooner, and painting it in the page's own
// background colour means there is no white flash before the UI arrives.
backgroundColor: "#06070a",
backgroundColor: appSettings.theme === "light" ? "#f3f5f8" : "#06070a",
icon: path.join(__dirname, "icon.ico"),
show: true,
show: !(process.argv.includes("--hidden") && appSettings.minimizeToTray),
webPreferences: {
preload: path.join(__dirname, "preload.js"),
contextIsolation: true,
Expand All @@ -779,16 +953,40 @@ function createWindow() {
});
win.setMenuBarVisibility(false);
win.loadFile(path.join(__dirname, "renderer", "index.html"));
if (process.argv.includes("--autostart") && appSettings.autoStartFarming) {
win.webContents.once("did-finish-load", () => {
if (isQuitting || !appSettings.autoStartFarming) return;
say("l_autostart_begin", "info");
runFlow({ startup: true });
});
}
win.on("close", (event) => {
if (!isQuitting && appSettings.minimizeToTray && ensureTray()) {
event.preventDefault();
win.hide();
}
});
win.on("closed", () => { win = null; });
if (!win.isVisible() && appSettings.minimizeToTray) ensureTray();
}

const gotLock = app.requestSingleInstanceLock();
if (!gotLock) {
app.quit();
} else {
app.on("second-instance", () => {
if (win) { if (win.isMinimized()) win.restore(); win.focus(); }
app.on("second-instance", () => showMainWindow());
app.whenReady().then(() => {
appSettings = readSettings();
applyStartupSetting();
syncTray();
createWindow();
});
app.on("activate", () => showMainWindow());
app.on("before-quit", () => {
isQuitting = true;
if (state.running) stopFlow();
});
app.on("window-all-closed", () => {
if (!appSettings.minimizeToTray) app.quit();
});
app.whenReady().then(createWindow);
app.on("window-all-closed", () => app.quit());
}
4 changes: 2 additions & 2 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "orbsniper",
"version": "1.6.0",
"version": "1.7.0",
"description": "OrbSniper farms Discord Orbs for you. Auto-accepts, completes and claims Discord Quests while you AFK. No token needed.",
"keywords": [
"discord",
Expand Down
5 changes: 5 additions & 0 deletions preload.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,17 @@ contextBridge.exposeInMainWorld("sniper", {
openExternal: (url) => ipcRenderer.invoke("app:open", url),
getVersion: () => ipcRenderer.invoke("app:version"),
getDonateAddress: () => ipcRenderer.invoke("app:donateAddress"),
getSettings: () => ipcRenderer.invoke("app:getSettings"),
saveSettings: (patch) => ipcRenderer.invoke("app:saveSettings", patch),
minimize: () => ipcRenderer.invoke("win:minimize"),
close: () => ipcRenderer.invoke("win:close"),
onLog: (cb) => ipcRenderer.on("sniper:log", (_, m) => cb(m)),
onSay: (cb) => ipcRenderer.on("sniper:say", (_, m) => cb(m)),
onEvent: (cb) => ipcRenderer.on("sniper:event", (_, m) => cb(m)),
onProgress: (cb) => ipcRenderer.on("sniper:progress", (_, m) => cb(m)),
onQuests: (cb) => ipcRenderer.on("sniper:quests", (_, m) => cb(m)),
onAccount: (cb) => ipcRenderer.on("sniper:account", (_, m) => cb(m)),
onBalance: (cb) => ipcRenderer.on("sniper:balance", (_, m) => cb(m)),
onTally: (cb) => ipcRenderer.on("sniper:tally", (_, m) => cb(m)),
onPhase: (cb) => ipcRenderer.on("sniper:phase", (_, m) => cb(m)),
onDone: (cb) => ipcRenderer.on("sniper:done", (_, m) => cb(m)),
Expand Down
Loading