Created
December 26, 2025 11:37
-
-
Save cbuctok/cf7f64a8bc6464bad7aeaa38bdd6ee45 to your computer and use it in GitHub Desktop.
Accept all pending invitations in Element Web 1.12.7
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
| // Master script to accept all remaining invites | |
| (async () => { | |
| let totalSuccess = 0; | |
| let totalFailure = 0; | |
| let batchNum = 1; | |
| const allResults = []; | |
| // Click on the Invites filter first | |
| const filterOptions = document.querySelectorAll('[role="option"]'); | |
| for (let option of filterOptions) { | |
| if (option.textContent.trim() === 'Invites') { | |
| option.click(); | |
| break; | |
| } | |
| } | |
| await new Promise(resolve => setTimeout(resolve, 1000)); | |
| // Keep accepting invites until none are left | |
| let hasMoreInvites = true; | |
| while (hasMoreInvites) { | |
| allResults.push(`--- Batch ${batchNum} ---`); | |
| let batchSuccess = 0; | |
| let batchFailure = 0; | |
| // Try to accept 10 invites per batch | |
| for (let i = 1; i <= 10; i++) { | |
| try { | |
| // Wait 2 seconds between invites | |
| if (i > 1) { | |
| await new Promise(resolve => setTimeout(resolve, 2000)); | |
| } | |
| // Get all room options | |
| const allOptions = document.querySelectorAll('[role="option"]'); | |
| // Find the first unselected room (skip filter options) | |
| let nextInvite = null; | |
| const filterNames = ['Unreads', 'People', 'Rooms', 'Favourites', 'Mentions', 'Invites', 'Low priority']; | |
| for (let option of allOptions) { | |
| const text = option.textContent.trim(); | |
| const isActive = option.getAttribute('aria-selected') === 'true'; | |
| if (!isActive && text && !filterNames.includes(text)) { | |
| nextInvite = option; | |
| break; | |
| } | |
| } | |
| if (!nextInvite) { | |
| hasMoreInvites = false; | |
| allResults.push(`Batch ${batchNum} Invite ${i}: No more invites found`); | |
| batchFailure++; | |
| break; | |
| } | |
| nextInvite.click(); | |
| await new Promise(resolve => setTimeout(resolve, 2000)); | |
| const complementary = document.querySelector('[role="complementary"]'); | |
| if (complementary) { | |
| const buttons = complementary.querySelectorAll('div[role="button"], button'); | |
| let foundAccept = false; | |
| for (let btn of buttons) { | |
| const btnText = btn.textContent.trim(); | |
| if (btnText === 'Accept') { | |
| btn.click(); | |
| foundAccept = true; | |
| await new Promise(resolve => setTimeout(resolve, 500)); | |
| break; | |
| } | |
| } | |
| if (foundAccept) { | |
| allResults.push(`Batch ${batchNum} Invite ${i}: ✓ Accepted`); | |
| batchSuccess++; | |
| totalSuccess++; | |
| } else { | |
| allResults.push(`Batch ${batchNum} Invite ${i}: Failed - no accept button`); | |
| batchFailure++; | |
| totalFailure++; | |
| } | |
| } else { | |
| allResults.push(`Batch ${batchNum} Invite ${i}: Failed - no dialog`); | |
| batchFailure++; | |
| totalFailure++; | |
| } | |
| } catch (error) { | |
| allResults.push(`Batch ${batchNum} Invite ${i}: Error - ${error.message}`); | |
| batchFailure++; | |
| totalFailure++; | |
| } | |
| } | |
| allResults.push(`Batch ${batchNum} Summary: ${batchSuccess} accepted, ${batchFailure} failed`); | |
| allResults.push(""); | |
| batchNum++; | |
| // Stop if we've processed 5 batches or no more invites | |
| if (!hasMoreInvites || batchNum > 20) break; | |
| } | |
| return { | |
| totalSummary: `Total: ${totalSuccess} invites accepted, ${totalFailure} failures`, | |
| results: allResults | |
| }; | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment