Created
January 24, 2021 19:20
-
-
Save sbolel/2bd2ed17f74d82d382693d1666a72714 to your computer and use it in GitHub Desktop.
Amazon Alexa Delete Recordings
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
/** | |
* @usage copy and paste into dev console at URL: | |
* https://www.amazon.com/alexa-privacy/apd/rvh | |
* @todo scroll to bottom to load more recordings once all loaded | |
* recordings are tested and the desired recordings are deleted. | |
*/ | |
(function(document) { | |
const CLICK_DELAY = 500 | |
const DELETE_BTN_SELECTOR = '.record-delete-banner.clickable' | |
/* add more text content of recordings to delete to this array */ | |
const TEXT_TO_DELETE = [ | |
'Audio was not intended for this device', | |
'Audio could not be understood', | |
'No text stored', | |
] | |
const nodes = document.querySelectorAll('.apd-content-box') | |
const elsToDelete = Array.prototype | |
.slice | |
.call(nodes) | |
.filter( | |
({ | |
id = '', | |
firstChild: { | |
innerText: childText = '', | |
} = {}, | |
}) => TEXT_TO_DELETE.indexOf(childText) > -1 | |
) | |
const delFn = (i = 0) => { | |
if (i < elsToDelete.length) { | |
const { lastChild } = elsToDelete[i] | |
lastChild.click() | |
setTimeout(() => { | |
const deleteBtn = document.querySelector(DELETE_BTN_SELECTOR) | |
if (deleteBtn) { | |
deleteBtn.click() | |
} | |
setTimeout(() => { | |
const next = i + 1; | |
if (next < elsToDelete.length) { | |
return delFn(next) | |
} | |
}, CLICK_DELAY) | |
}, CLICK_DELAY * 3) | |
} | |
} | |
delFn() | |
})(document) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment