Skip to content

Aplikasi desktop berbasis Electron untuk melakukan otomatisasi Instagram menggunakan ADB (Android Debug Bridge) dengan banyak device Android secara paralel.

JavaScript

Initial commit

PT BRAVO CREATIVE WORKS7c036ee51905
diff --git a/main.js b/main.js
index 2226894..dfef3c1 100644
--- a/main.js
+++ b/main.js
@@ -173,7 +173,6 @@ ipcMain.handle("export-devices-excel", async (event, deviceList) => {
views: [{ state: "frozen", ySplit: 1 }]
});
- // Define columns
sheet.columns = [
{ header: "No", key: "no", width: 6 },
{ header: "Device ID", key: "device", width: 22 },
@@ -183,7 +182,6 @@ ipcMain.handle("export-devices-excel", async (event, deviceList) => {
{ header: "Status", key: "status", width: 15 }
];
- // HEADER DESIGN
const header = sheet.getRow(1);
header.height = 28;
@@ -212,7 +210,6 @@ ipcMain.handle("export-devices-excel", async (event, deviceList) => {
};
});
- // BODY DATA
deviceList.forEach((d, i) => {
const row = sheet.addRow({
no: i + 1,
@@ -224,39 +221,28 @@ ipcMain.handle("export-devices-excel", async (event, deviceList) => {
});
row.height = 22;
-
- // Zebra Style
const zebra = i % 2 === 0 ? "FFF5F5F5" : "FFFFFFFF";
row.eachCell((cell, colNum) => {
- // Fill background
cell.fill = {
type: "pattern",
pattern: "solid",
fgColor: { argb: zebra }
};
-
- // Base text font
cell.font = {
size: 11,
name: "Segoe UI"
};
-
- // Alignment
cell.alignment = {
vertical: "middle",
horizontal: colNum === 5 || colNum === 6 ? "center" : "left"
};
-
- // Border clean thin
cell.border = {
top: { style: "thin" },
left: { style: "thin" },
bottom: { style: "thin" },
right: { style: "thin" }
};
-
- // STATUS COLORING
if (colNum === 6) {
cell.font = {
bold: true,
@@ -269,8 +255,6 @@ ipcMain.handle("export-devices-excel", async (event, deviceList) => {
}
});
});
-
- // Auto filter
sheet.autoFilter = {
from: { row: 1, column: 1 },
to: { row: 1, column: 6 }
diff --git a/modules/device.js b/modules/device.js
index e5548b0..e22dcca 100644
--- a/modules/device.js
+++ b/modules/device.js
@@ -148,16 +148,13 @@ async function scanFullOLD() {
async function restartInstagram(deviceId) {
try {
- // Force stop IG
await run(adbCmd(`-s ${deviceId} shell am force-stop com.instagram.android`));
await delay(500);
-
- // Start IG normal
await run(adbCmd(
`-s ${deviceId} shell am start -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -n com.instagram.android/.activity.MainTabActivity`
));
- await delay(1500); // beri waktu IG membuka
+ await delay(1500);
} catch (e) {
console.log(`❌ Gagal restart IG di device ${deviceId}`, e);
}
@@ -168,22 +165,17 @@ async function scanFull() {
const devices = await getDevices();
if (devices.length === 0) return [];
- const BATCH_SIZE = 10; // aman untuk 100 device
+ const BATCH_SIZE = 10;
const results = [];
- // bagi menjadi beberapa batch
for (let i = 0; i < devices.length; i += BATCH_SIZE) {
const batch = devices.slice(i, i + BATCH_SIZE);
console.log(`🚀 Memproses batch ${i / BATCH_SIZE + 1} (${batch.length} device)...`);
-
- // jalankan paralel untuk batch ini
const batchResults = await Promise.all(
batch.map(dev => safeScanDevice(dev))
);
results.push(...batchResults);
-
- // beri jeda ringan antar batch agar ADB tidak overload
await delay(500);
}
@@ -192,10 +184,7 @@ async function scanFull() {
async function safeScanDevice(dev) {
try {
- // Restart IG dulu
await restartInstagram(dev);
-
- // Jalankan scan detail
return await scanOneDevice(dev);
} catch (err) {