Created
September 27, 2024 19:09
-
-
Save ZettZet/cf325eee1f511b7ad5bf391d3305f698 to your computer and use it in GitHub Desktop.
Deleting files from OneDrive is difficult, especially if you want to delete thousands at once. The settings delete button does not work, and you can delete only 50 files at once.
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
| setInterval(() => { | |
| Array.from(document.querySelectorAll('[aria-labelledby]')) | |
| .slice(0, 50) | |
| .forEach((item) => { | |
| const id = item.getAttribute('aria-labelledby') | |
| document.getElementById(id).click() | |
| }) | |
| document.querySelector('button[data-automationid="deleteCommand"]').click() | |
| waitForElm('button[data-automationid="confirmbutton"]').then((element) => element.click()) | |
| }, 100) | |
| function waitForElm(selector) { | |
| return new Promise((resolve) => { | |
| const element = document.querySelector(selector) | |
| if (element) { | |
| return resolve(element) | |
| } | |
| const observer = new MutationObserver(() => { | |
| const element = document.querySelector(selector) | |
| if (element) { | |
| observer.disconnect() | |
| resolve(element) | |
| } | |
| }) | |
| observer.observe(document.body, { | |
| childList: true, | |
| subtree: true, | |
| }) | |
| }) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment