Created
November 1, 2022 22:11
-
-
Save trumad/cf454af1e41d138791811ab272a6d030 to your computer and use it in GitHub Desktop.
JS to delete all files from an archive.org item
This file contains 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
function searchText(elementType,text){ | |
var xpath = `//${elementType}[contains(text(),'${text}')]`; | |
var matchingElement = document.evaluate(xpath, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue; | |
return matchingElement; | |
} | |
function sleep(ms) { // usage: await sleep(4000) | |
return new Promise(resolve => setTimeout(resolve, ms)); | |
} | |
var files = document.querySelectorAll(".x-tree-node-anchor") | |
async function go(){ | |
for (let item of files){ | |
if (item.textContent.includes('Tree Root') | |
|| item.textContent.includes('xml') | |
){continue} | |
item.click(); | |
await sleep(100); | |
//document.querySelector("#ext-gen26").click() // file | |
searchText('button','File').click() | |
await sleep(700); | |
//document.querySelector("#ext-gen459").click() // delete | |
searchText('a','Delete Key').click() | |
await sleep(300); | |
//document.querySelector("#ext-gen531").click() // yes | |
searchText('button','Yes').click() | |
await sleep(300); | |
} | |
} | |
go(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment