Last active
December 4, 2025 13:38
-
-
Save richardARPANET/7e36b5d32312df540fb217a7e92338b6 to your computer and use it in GitHub Desktop.
Instagram delete ALL Direct Messages
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| INSTRUCTIONS: | |
| 1. Go to: https://www.instagram.com/direct/inbox/ | |
| 2. Open Developer Tools → Console. | |
| 3. Paste the entire script and press Enter. | |
| 4. It will: | |
| - Skip the first convo | |
| - Delete the second | |
| - Re-scan the list each loop | |
| - Wait only what is absolutely needed | |
| - AFTER DELETE → Wait 1 second | |
| - Auto-restart every 10 minutes (no page reload) | |
| */ | |
| (function startScript() { | |
| async function runBatch() { | |
| const sleep = ms => new Promise(r => setTimeout(r, ms)); | |
| const BATCH_TIME = 10 * 60 * 1000; // 10 minutes | |
| const batchStart = Date.now(); | |
| async function waitForAriaLabel(label, timeoutMs = 2000) { | |
| const target = label.toLowerCase(); | |
| const start = Date.now(); | |
| while (Date.now() - start < timeoutMs) { | |
| let el = | |
| document.querySelector(`svg[aria-label="${label}"]`) || | |
| document.querySelector(`[aria-label="${label}"]`); | |
| if (!el) { | |
| el = [...document.querySelectorAll('[aria-label]')].find(e => | |
| e.getAttribute('aria-label')?.toLowerCase() === target | |
| ); | |
| } | |
| if (el) return el; | |
| await sleep(100); | |
| } | |
| return null; | |
| } | |
| async function waitForText(text, timeoutMs = 2000) { | |
| const target = text.toLowerCase(); | |
| const start = Date.now(); | |
| while (Date.now() - start < timeoutMs) { | |
| const el = [...document.querySelectorAll('button, div, span, a')].find(e => { | |
| const t = e.textContent && e.textContent.trim().toLowerCase(); | |
| return t === target; | |
| }); | |
| if (el) return el; | |
| await sleep(100); | |
| } | |
| return null; | |
| } | |
| while (true) { | |
| // Restart after 10 minutes | |
| if (Date.now() - batchStart > BATCH_TIME) { | |
| console.log("10 minutes passed — restarting script logic."); | |
| startScript(); | |
| return; | |
| } | |
| const convoImgs = document.querySelectorAll( | |
| 'section > main > div > section img' | |
| ); | |
| console.log("Found convo images:", convoImgs.length); | |
| if (convoImgs.length < 2) { | |
| console.log("No more deletable conversations (0/1). Stopping batch."); | |
| break; | |
| } | |
| const img = convoImgs[1]; | |
| console.log("Deleting convo (skipping first):", img); | |
| // 1) Click convo | |
| try { | |
| img.scrollIntoView({ block: "center" }); | |
| img.click(); | |
| console.log("Clicked convo image."); | |
| } catch (e) { | |
| console.warn("Failed to click convo:", e); | |
| await sleep(200); | |
| continue; | |
| } | |
| await sleep(150); | |
| // 2) Info icon | |
| const infoEl = await waitForAriaLabel("Conversation information", 2000); | |
| if (!infoEl) { | |
| console.warn("Info icon not found — skipping convo."); | |
| continue; | |
| } | |
| (infoEl.parentElement || infoEl).click(); | |
| console.log("Clicked info icon."); | |
| await sleep(150); | |
| // 3) Delete Chat | |
| const deleteChatBtn = await waitForText("Delete Chat", 2000); | |
| if (!deleteChatBtn) { | |
| console.warn('"Delete Chat" not found — skipping.'); | |
| continue; | |
| } | |
| deleteChatBtn.click(); | |
| console.log('Clicked "Delete Chat".'); | |
| await sleep(150); | |
| // 4) Confirm Delete | |
| const confirmBtn = await waitForText("Delete", 2000); | |
| if (!confirmBtn) { | |
| console.warn('"Delete" confirm not found.'); | |
| continue; | |
| } | |
| confirmBtn.click(); | |
| console.log('Clicked confirm "Delete".'); | |
| // 👉 ***1 second settle time after delete*** | |
| await sleep(1000); | |
| } | |
| console.log("Batch done. Restarting in 1 second…"); | |
| await sleep(2000); | |
| startScript(); | |
| } | |
| runBatch(); | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment