Skip to content

Instantly share code, notes, and snippets.

@mfurlend
Created October 4, 2018 16:19
Show Gist options
  • Save mfurlend/e131fe9daaecc59b65af671be8d216db to your computer and use it in GitHub Desktop.
Save mfurlend/e131fe9daaecc59b65af671be8d216db to your computer and use it in GitHub Desktop.
webtorrent-desktop batch delete scripts
//Delete all
let delete_buttons = Array.from(document.getElementsByClassName('delete'))
while (delete_buttons.length > 0) {
let button = delete_buttons.pop();
button.click();
Array.from(document.querySelector('.control.ok').getElementsByTagName('*')).forEach(o=>o.click());
}
// Delete paused
let delete_buttons = Array.from(document.getElementsByClassName('delete')).filter(o=>o.parentNode.parentNode.childNodes[0].childNodes[1].childNodes[0].classList.contains('paused'))
while (delete_buttons.length > 0) {
let button = delete_buttons.pop();
button.click();
Array.from(document.querySelector('.control.ok').getElementsByTagName('*')).forEach(o=>o.click());
}
// Delete seeding
let delete_buttons = Array.from(document.getElementsByClassName('delete')).filter(o=>o.parentNode.parentNode.childNodes[0].childNodes[1].childNodes[0].classList.contains('seeding'))
while (delete_buttons.length > 0) {
let button = delete_buttons.pop();
button.click();
Array.from(document.querySelector('.control.ok').getElementsByTagName('*')).forEach(o=>o.click());
}
// Delete non-downloading
let delete_buttons = Array.from(document.getElementsByClassName('delete')).filter(o=>!o.parentNode.parentNode.childNodes[0].childNodes[1].childNodes[0].classList.contains('downloading'))
while (delete_buttons.length > 0) {
let button = delete_buttons.pop();
button.click();
Array.from(document.querySelector('.control.ok').getElementsByTagName('*')).forEach(o=>o.click());
}
// Delete all, keep top
let delete_buttons = Array.from(document.getElementsByClassName('delete'))
while (delete_buttons.length > 1) {
let button = delete_buttons.pop();
button.click();
Array.from(document.querySelector('.control.ok').getElementsByTagName('*')).forEach(o=>o.click());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment